-
Notifications
You must be signed in to change notification settings - Fork 19
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Enable OPTIONS preflight and a method to enable cros origins #359
Conversation
tests are failing |
index.js
Outdated
@@ -136,7 +139,7 @@ function initializeServer(config) { | |||
// Add a parser for application/x-www-form-urlencoded | |||
server.addContentTypeParser( | |||
'application/x-www-form-urlencoded', | |||
function(_, payload, done) { | |||
function (_, payload, done) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
unrelated formatting
index.js
Outdated
@@ -156,7 +159,7 @@ function initializeServer(config) { | |||
server.addContentTypeParser( | |||
'*', | |||
{ parseAs: 'buffer' }, | |||
function(req, body, done) { | |||
function (req, body, done) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
unrelated formatting
lib/invoker.js
Outdated
'access-control-allow-methods': | ||
'OPTIONS, GET, DELETE, POST, PUT, HEAD, PATCH', | ||
'access-control-allow-origin': '*' | ||
'access-control-allow-methods': 'OPTIONS, GET, POST', |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
why are you removing the other methods(DELETE, PUT, HEAD, PATCH)? This should stay the same since it is the default, otherwise it would be a breaking change
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
invocation-handler.js
module.exports = function use(fastify, opts, done) {
fastify.get('/', doGet);
fastify.post('/', doPost);
fastify.options('/', doOptions);
const invokeFunction = invoker(opts);
As you can see here, only the post and get were supported and now i added options. Why should the rest of the methods be allowed if they cannot be used? Anyway, I added the rest of allowed methods in cors.
@lholmquist I fixed the code, according to the tests and removed formatting differences. Can you take another look? Thanks |
Hello @lholmquist , can you take a look at this PR? |
@giurgiur99 can you please add a test/tests for this new functionality? |
@lholmquist I added tests for preflight and allowed origins |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
looks good. the ci is failing, but not because of this PR
Reasoning
Changes