-
Notifications
You must be signed in to change notification settings - Fork 0
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
Why is CORS not working? #1
Comments
Finally got time to look into it 😃 Everything looks fine for now. Have you tried to enable CORS globally like this: https://github.com/JustServerless/discuss/blob/master/s-project.json#L7-L10 P.S. Which Serverless version are you using? |
And you redeployed with |
Yes. Could the undefined vars be an issue?
I also just realized the https vs http may be a problem, but that doesn't seem like it either. Same error (although API Gateway does appear to only accept https input) |
The variables might not be a problem (see here). I would recommend to open up an issue at https://github.com/joostfarla/serverless-cors-plugin/issues as @joostfarla may know more (because he's the author of the plugin and knows it's internals inside out). |
Ok – I'll give that a shot. Thanks for checking it out. On Wed, Jun 1, 2016 at 9:36 AM, Philipp Muens notifications@github.com
Reilly Sweetland |
Hi @rsweetland, Just had a look at your test-page! The preflight (OPTIONS) endpoint is successfully deployed and it returns the correct status code and headers. It looks like API gateway returns an error (400) response on the actual POST request which does not contain the CORS headers. Could you try fixing the function so that it returns a 200 OK status? Or check your Cloudwatch logs to see why it is return a 400 error? Normally all error responses should contain the CORS headers, but it could be that your function has problems with matching content types for the request or response. Cheers, Joost |
@joostfarla Really appreciate you finding this and helping me debug! You were right – the client JS was malformed, causing the whole thing to fail. I think API Gateway was rejecting the request before it made it to the Cloudwatch logs, making it a bit difficult to debug. With commit 99ad31f everything is working. Thanks again! |
I've installed Serverless CORS, and S3 plugins.
On index.html in client/dist, I'm executing this js:
Submitting to the serverless endpoint (https://lqua9t0r4g.execute-api.us-east-1.amazonaws.com/dev/testPost) with postman works:
Submitting to same endpoint from this static file on S3 fails:
I've created another, alternate endpoint that just uses PHP which works fine (commented out in above source code):
The test front-end currently points to the misconfigured CORS endpoint for easy dev-tools inspection, etc: http://s3.amazonaws.com/sandbox.sls.test.cors/index.html
The text was updated successfully, but these errors were encountered: