h3 icon indicating copy to clipboard operation
h3 copied to clipboard

Add CORS

Open jolo-dev opened this issue 1 year ago • 4 comments

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?

jolo-dev avatar May 02 '24 08:05 jolo-dev

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) {
      // ..
      }
  })
)

jolo-dev avatar May 02 '24 15:05 jolo-dev

Definitely a good thing to document. Utils are listed but need info. PR welcome!

TheAlexLichter avatar May 05 '24 12:05 TheAlexLichter

@manniL I would do a PR but is that above correct what I did? :D

jolo-dev avatar May 07 '24 08:05 jolo-dev

@jolo-dev Seems right to me, yes 👍🏻 Would probably rename const cors to const didHandleCors and do if(didHandleCors) { return } ☺️

TheAlexLichter avatar May 07 '24 09:05 TheAlexLichter

Should have been resolved in #747.

kricsleo avatar Apr 24 '25 07:04 kricsleo