h3
h3 copied to clipboard
Add CORS
Describe the change
Honestly, I have trouble understanding how CORS here works.
It would be nice if we could add it to the documentation.
URLs
No response
Additional information
- [x] Would you be willing to help?
I did in the end for my router this:
router.use('/',
defineEventHandler(async (event) => {
const cors = handleCors(event, {
origin: '*',
preflight: {
statusCode: 204,
},
methods: '*',
});
if (!cors) {
// ..
}
})
)
Definitely a good thing to document. Utils are listed but need info. PR welcome!
@manniL I would do a PR but is that above correct what I did? :D
@jolo-dev Seems right to me, yes 👍🏻 Would probably rename const cors to const didHandleCors and do if(didHandleCors) { return } ☺️
Should have been resolved in #747.