ambiorix-web / ambiorix

🖥️ Web framework for R
http://ambiorix.dev
GNU General Public License v3.0
211 stars 9 forks source link

Added Options Method #39

Closed RyanBrunoUSDC closed 3 years ago

RyanBrunoUSDC commented 3 years ago

Because Ambiorix is unopinionated it should give users the ability to handle the OPTIONS http method. With this in place you can handle CORS pre-flight requests like:

app$options("/route", function(req, res) {
    res$send("", headers = list(
                        `Access-Control-Allow-Origin` = "*",
                        `Access-Control-Allow-Methods` = "*",
                        `Access-Control-Allow-Headers` = "*"))
})

app$all is left alone to not break existing code. But this is up to the maintainers.

JohnCoene commented 3 years ago

I had overlooked this thank you.

{ambiorix} takes inspiration from express.js which allows adding headers on the response object (res) with a method, e.g.: addHeader("Access-Control-Allow-Origin", "*")

JohnCoene commented 3 years ago

Sorry, misread your PR, apologies.