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

routeRoules cors: true does not work for /api routes #25686

Closed
MickL opened this issue Feb 7, 2024 · 3 comments
Closed

routeRoules cors: true does not work for /api routes #25686

MickL opened this issue Feb 7, 2024 · 3 comments

Comments

@MickL
Copy link

MickL commented Feb 7, 2024

Environment

Describe the bug

Settings cors: true works for routes in the public folder but not in /api:

routeRules: {
    '/my-public-folder': {
      cors: true,
    },
    '/api/my-api-function': {
      cors: true
    },
  },

Workaround

Use nuxt-security module:

routeRules: {
    '/my-public-folder': {
      cors: true,
    },
    '/api/my-api-function': {
      security: {
        corsHandler: {
          origin: '*',
          methods: '*',
          allowHeaders: '*',
          exposeHeaders: '*',
        },
      },
    },
  },

Logs

No response

@danielroe
Copy link
Member

Would you see if you can reproduce this in pure Nitro (reproduction sandbox), and if so, raise there? 🙏

@MickL
Copy link
Author

MickL commented Apr 5, 2024

It is not working for Nitro as well, issue: unjs/nitro#2340

@MickL MickL closed this as completed Apr 5, 2024
@MickL MickL reopened this May 22, 2024
@danielroe
Copy link
Member

Let's track in the nitro issue - it's not a Nuxt-specific issue.

@danielroe danielroe closed this as not planned Won't fix, can't repro, duplicate, stale May 22, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants