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

Add CORS #744

Open
1 task done
jolo-dev opened this issue May 2, 2024 · 4 comments
Open
1 task done

Add CORS #744

jolo-dev opened this issue May 2, 2024 · 4 comments
Labels
documentation Improvements or additions to documentation good first issue Good for newcomers

Comments

@jolo-dev
Copy link

jolo-dev commented May 2, 2024

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

  • Would you be willing to help?
@jolo-dev jolo-dev added the documentation Improvements or additions to documentation label May 2, 2024
@jolo-dev
Copy link
Author

jolo-dev commented May 2, 2024

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

@manniL
Copy link
Member

manniL commented May 5, 2024

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

@manniL manniL added the good first issue Good for newcomers label May 5, 2024
@jolo-dev
Copy link
Author

jolo-dev commented May 7, 2024

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

@manniL
Copy link
Member

manniL commented May 7, 2024

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
documentation Improvements or additions to documentation good first issue Good for newcomers
Projects
None yet
Development

No branches or pull requests

2 participants