Did anyone manage to handle CORS with h3/nuxt/nitro?
I'm trying everything like this:
I always get:
request blocked: (Reason: CORS header ‘Access-Control-Allow-Origin’ missing).
11 Replies
There is a CORS route rule which you could use 🙂
https://github.com/unjs/nitro/blob/aabdc9c5c78c011a212c754058160ed23391361d/src/options.ts#L514-L522 implementation
GitHub
nitro/src/options.ts at aabdc9c5c78c011a212c754058160ed23391361d · ...
Next Generation Server Toolkit. Create web servers with everything you need and deploy them wherever you prefer. - unjs/nitro
but
handleCors
should cover it all alreadyGitHub
h3/src/utils/cors/handler.ts at 58e33ff00b1db1cf86a780bf8b152c3f7e5...
⚡️ Minimal H(TTP) framework built for high performance and portability - unjs/h3
you don't even need to pass options as the defaults should cover "allow all"
I'm also running into this issue, and handleCors isn't handling it at all
Can you provide a reproduction?
Also the h3 docs were updated on it
I realize my situation isn't exactly identitcal, as I am using h3, but not nitro
Should still work with h3 only though
I nuked my entire project and restarted and now it’s working
Not helpful at all, but I’m on a time crunch 😬
Maybe was an old h3 version?
Anyway happy it helps