[GH-ISSUE #98] Unable to fetch() from API due to CORS policy. #8898

Closed
opened 2026-04-24 14:56:55 -05:00 by GiteaMirror · 7 comments
Owner

Originally created by @jojobii-arks on GitHub (Mar 28, 2023).
Original GitHub issue: https://github.com/imputnet/cobalt/issues/98

Issue

  • Access-Control-Allow-Origin header isn't present on preflight response, resulting in the fetch being rejected.
Access to fetch at 'https://co.wukko.me/api/json' from origin ******* has been blocked by CORS policy: Response to preflight request doesn't pass access control check: No 'Access-Control-Allow-Origin' header is present on the requested resource. If an opaque response serves your needs, set the request's mode to 'no-cors' to fetch the resource with CORS disabled.

Possible Solution

Originally created by @jojobii-arks on GitHub (Mar 28, 2023). Original GitHub issue: https://github.com/imputnet/cobalt/issues/98 ## Issue - `Access-Control-Allow-Origin` header isn't present on preflight response, resulting in the fetch being rejected. ``` Access to fetch at 'https://co.wukko.me/api/json' from origin ******* has been blocked by CORS policy: Response to preflight request doesn't pass access control check: No 'Access-Control-Allow-Origin' header is present on the requested resource. If an opaque response serves your needs, set the request's mode to 'no-cors' to fetch the resource with CORS disabled. ``` - Unable to use `{cors: 'no-cors'}` within `fetch` options param since it just reverts the `content-type` back to `plain/text`, resulting in an incorrect ContentType for the JSON middleware used here: https://github.com/wukko/cobalt/blob/adba73d60c43c4358dd4f71c65070c185773064a/src/cobalt.js#L70 ## Possible Solution - Add middleware that sets `Access-Control-Allow-Origin` to `*` to allow for CORS. I did this on my fork if you wanna take a lookie .3. https://github.com/jojobii-arks/cobalt-epic-style/commit/3972535eff5bbe0cfe677334c7e9d15afa83eae6
Author
Owner

@kotobdev commented on GitHub (Mar 28, 2023):

I ran across the same issue when making my own extension, I "solved" it by changing my nginx config a bit- but having an actual fix would be nice :)

<!-- gh-comment-id:1487148478 --> @kotobdev commented on GitHub (Mar 28, 2023): I ran across the same issue when making my own extension, I "solved" it by changing my nginx config a bit- but having an actual fix would be nice :)
Author
Owner

@ReznorsRevenge1 commented on GitHub (Jul 11, 2024):

Uhh, I'm still having this exact problem.

<!-- gh-comment-id:2223923781 --> @ReznorsRevenge1 commented on GitHub (Jul 11, 2024): Uhh, I'm still having this exact problem.
Author
Owner

@dumbmoron commented on GitHub (Jul 11, 2024):

Uhh, I'm still having this exact problem.

are you having this problem on your own instance, or on the main instance (api.cobalt.tools)?

<!-- gh-comment-id:2224066318 --> @dumbmoron commented on GitHub (Jul 11, 2024): > Uhh, I'm still having this exact problem. are you having this problem on your own instance, or on the main instance (api.cobalt.tools)?
Author
Owner

@ihatespawn commented on GitHub (Jul 11, 2024):

why are people commenting on a 1 year old issue
can't you just open a new one?

<!-- gh-comment-id:2224079128 --> @ihatespawn commented on GitHub (Jul 11, 2024): why are people commenting on a 1 year old issue can't you just open a new one?
Author
Owner

@ReznorsRevenge1 commented on GitHub (Jul 12, 2024):

The api.cobalt.tools

<!-- gh-comment-id:2225960522 --> @ReznorsRevenge1 commented on GitHub (Jul 12, 2024): The api.cobalt.tools
Author
Owner

@ReznorsRevenge1 commented on GitHub (Jul 12, 2024):

why are people commenting on a 1 year old issue can't you just open a new one?

Why should I, if there is already an issue describing the exact problem I'm having?

<!-- gh-comment-id:2225961599 --> @ReznorsRevenge1 commented on GitHub (Jul 12, 2024): > why are people commenting on a 1 year old issue can't you just open a new one? Why should I, if there is already an issue describing the exact problem I'm having?
Author
Owner

@ihatespawn commented on GitHub (Jul 12, 2024):

it was resolved a year ago, there is a better chance of someone helping you with that (i have notifications for cobalt but not everyone that could help you has them) and most of the people don't like necroposting. oh, and it also makes it less confusing for people like me.

oh, and also there are templates that ask you for information to make helping faster.

you don't have the exactly same issue. this issue is about the access-control-allow-origin header not being set to '*' and it's now fixed
image
yours is different and you didn't even provide any information or code

so, you should just create a new issue, here's the template for that: https://github.com/imputnet/cobalt/issues/new?assignees=&labels=main+instance+issue&projects=&template=bug-main-instance.md&title=%5Bshort+description+of+the+bug%5D

<!-- gh-comment-id:2226022313 --> @ihatespawn commented on GitHub (Jul 12, 2024): it was resolved a year ago, there is a better chance of someone helping you with that (i have notifications for cobalt but not everyone that could help you has them) and most of the people don't like necroposting. oh, and it also makes it less confusing for people like me. oh, and also there are templates that ask you for information to make helping faster. you don't have the exactly same issue. this issue is about the access-control-allow-origin header not being set to '*' and it's now fixed ![image](https://github.com/user-attachments/assets/560dd5f8-6a88-4fdb-b212-1d8d230bb052) yours is different and you didn't even provide any information or code so, you should just create a new issue, here's the template for that: https://github.com/imputnet/cobalt/issues/new?assignees=&labels=main+instance+issue&projects=&template=bug-main-instance.md&title=%5Bshort+description+of+the+bug%5D
Sign in to join this conversation.