Skip to content
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

CORS middleware official example is not working #17815

Closed
jca41 opened this issue Oct 12, 2020 · 2 comments
Closed

CORS middleware official example is not working #17815

jca41 opened this issue Oct 12, 2020 · 2 comments

Comments

@jca41
Copy link

jca41 commented Oct 12, 2020

Bug report

Describe the bug

The official guide for adding CORS to a next.js API route is not working correctly.

https://github.com/vercel/next.js/tree/canary/examples/api-routes-cors

To Reproduce

Steps to reproduce the behavior, please provide code snippets or a repository:

  1. Follow the official guide and add CORS to a route
  2. Set an example CORS config

{ origin: false, methods: ['POST'] }
3. npm run dev
4. Hit the API route with a disallowed HTTP method (ex. GET)

Expected behavior

The request should fail and i should see a CORS error on my browser console

System information

  • OS:Linux
  • Browser: Chrome
  • Version of Next.js: 9.5.5
  • Version of Node.js: 13.9.0

Additional context

Reported here also #16441 (comment)

@timneutkens
Copy link
Member

#17814 (comment)

CORS only covers returning which methods are allowed, not actually blocking the methods.

@balazsorban44
Copy link
Member

This issue has been automatically locked due to no recent activity. If you are running into a similar issue, please create a new issue with the steps to reproduce. Thank you.

@vercel vercel locked as resolved and limited conversation to collaborators Jan 29, 2022
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants