I am trying to get all types of requests to work with Nancy and CORS. Currently I add a pipeline at the end of the request:
pipelines.AfterReques
I don't think you need to specify OPTIONS as an allowed CORS method. I've never seen that set, and I've never set it myself. Browsers don't complain.
Otherside I have a similar setup as you in my :
public abstract class MyModule : NancyModule
protected MyModule(bool hasRazorView = true)
After.AddItemToEndOfPipeline((ctx) => ctx.Response
.WithHeader("Access-Control-Allow-Origin", "*")
.WithHeader("Access-Control-Allow-Methods", "POST,GET")
.WithHeader("Access-Control-Allow-Headers", "Accept, Origin, Content-type"));
. . . .
}
}
In my case, the CORS get sent on my GET and POST, but not the OPTIONS. I overrode the default OPTIONS handling with Options["/"] = route => new Response()
. That let the rest of the pipeline fire.