sailorproject / sailor

A Lua MVC Web Framework.
MIT License
921 stars 125 forks source link

Added support for CORS but requires patching remy as well #128

Closed soapdog closed 7 years ago

soapdog commented 7 years ago

Those using sailor to build API servers need some more advanced controls for dealing with HTTP headers. One common need is implementing CORS support so that the API server is able to respond to clients on different origins, this is all done through some juggling of HTTP headers.

To solve CORS, I have implemented a new function called page:enable_cors() which allows the developer to set all needed headers but to make this work, I also need to patch remy because the cgilua implementation there only outputs location headers and ignore all the rest.

I have already sent a PR to remy fixing this and am waiting for feedback. Since this PR blocks the current CORS implementation on Xavante (but potentially not on Apache) I decided not to send the PR to sailor right now.

In the meanwhile, you can check the implementation here:

https://github.com/amora-labs/sailor/tree/enhancement-cors (on page.lua)

Cheers andre

Etiene commented 7 years ago

Seems like the PR is merged! I'm gonna make a new remy release :) Then you can make a PR to sailor with this! 💃

Etiene commented 7 years ago

Done! You can PR this to sailor now! :D

felipedaragon commented 7 years ago

Merged in Remy as well _o/

soapdog commented 7 years ago

PR sent https://github.com/sailorproject/sailor/pull/131 :D :D