Valhalla OPTIONS request gets 405 - Method not allowed
nilsnolde opened this issue · 2 comments
I think it's a prime server issue, but happy to be told otherwise.
On browser preflight for a Valhalla POST request it fails on the OPTIONS request with a 405 - Method now allowed
. Of course it works easily with GET, but I do cringe a little when forcing Valhalla's request into GET 😉
Interestingly, I couldn't find any issue concerning preflight/OPTIONS/CORS on Valhalla or prime server. If you find the time, a nudge in the right direction would be appreciated.
@nilsnolde primserver will pass options requests down to valhalla, but valhalla only supports GET and POST at the moment. these lines of code reject anything else: https://github.com/valhalla/valhalla/blob/master/src/worker.cc#L1111-L1114 they throw a 101
exception which gets turned into an http 405
.
I would say at the moment options type requests hit at something that is a bit blurry at the moment. prime_server seeks to be a very lightweight server api where it provides just enough glue to let you get done what you want to. so in other words it forces you to implement all the bells and whistles you want for your specific applications needs. i could totally see moving things like on the fly compression and such up to the prime_server http protocol as options that downstream applications can "just use" especially because it does have some other stuff in there already, but at the moment its not something i've been focused on a lot.
i do think that the server should spend as little time as possible triaging requests and really just forwarding them to workers. i think the best thing to do here would be to add some convenience methods to the prime_server http protocol/utils to allow applications such as valhalla to "do the right thing" when they get bits of the request that aren't yet actionable in terms of the applications main purpose. the trick will be if some state is required to be visible in the next client communication. i dont think thats a problem for this specific issue you raise but it could be for other types of server interactions.
Thanks Kevin for the great information, as always.
I get what you're saying, at least in abstract terms. I think we'll just solve it in the web server layer before prime_server.