# No 'Access-Control-Allow-Origin' header is present on the requested resource

**URL:** <https://forum.gitea.com/t/no-access-control-allow-origin-header-is-present-on-the-requested-resource/2636>\
**Category:** Install/Maintain/Configure\
**Created:** [November 11, 2020, 8:06am UTC](https://forum.gitea.com/t/no-access-control-allow-origin-header-is-present-on-the-requested-resource/2636 "2020-11-11T08:06:04Z")\
**Posts on this page:** 9\
**Page:** 1

<div class="post-metadata">

**Author:** ![sumhm](https://avatars.discourse-cdn.com/v4/letter/s/e274bd/32.png) [@sumhm](https://forum.gitea.com/u/sumhm)\
**Post date:** [November 11, 2020, 8:06am UTC](https://forum.gitea.com/t/no-access-control-allow-origin-header-is-present-on-the-requested-resource/2636/1 "2020-11-11T08:06:04Z")

</div>

Hi guys!

Relatively new to gitea, but I’ve tried all methods I could find relevant on Google but to no avail.

So I have a react project that is trying to read data from a json file that is hosted on gitea using axios.

Here’s the error messages returned:

 ![image](https://us1.discourse-cdn.com/flex020/uploads/gitea/original/2X/6/6c8fa1854e79580d533cd3a328469e6299928de8.png)

I have tried changing the .ini file for gitea, changing my apache settings etc.

Would appreciate if someone could enlighten me on this!

Thank you!

---

<div class="post-metadata">

**Author:** ![jimafisk](https://avatars.discourse-cdn.com/v4/letter/j/9e8a1a/32.png) [@jimafisk](https://forum.gitea.com/u/jimafisk)\
**Post date:** [January 20, 2023, 10:40pm UTC](https://forum.gitea.com/t/no-access-control-allow-origin-header-is-present-on-the-requested-resource/2636/2 "2023-01-20T22:40:34Z")

</div>

Apparently this exists in Gitea ([Custom Access-Control-Allow-Origin header in raw data · Issue #4309 · go-gitea/gitea · GitHub](https://github.com/go-gitea/gitea/issues/4309)) but I don’t see an explanation of how to use it.

I found a similar issue from Gogs ([Access-Control-Allow-Origin · Issue #3987 · gogs/gogs · GitHub](https://github.com/gogs/gogs/issues/3987#issuecomment-323111774)) where they mentioned `ACCESS_CONTROL_ALLOW_ORIGIN` so I searched the Configuration Cheatsheet (sorry can’t link to it, I’m limited to 2 links for post as a new user) and tried implement it by adding the following to `/var/lib/gitea/custom/conf/app.ini`:

```auto
[repository]
ACCESS_CONTROL_ALLOW_ORIGIN = *

```

This does not seem to resolve the issue for me (even after restarting the service: `systemctl restart gitea`). Has anyone had luck resolving this? Thanks!

---

<div class="post-metadata">

**Author:** ![jake](https://avatars.discourse-cdn.com/v4/letter/j/f475e1/32.png) [@jake](https://forum.gitea.com/u/jake)\
**Post date:** [January 25, 2023, 4:53am UTC](https://forum.gitea.com/t/no-access-control-allow-origin-header-is-present-on-the-requested-resource/2636/3 "2023-01-25T04:53:11Z")

</div>

Can you try using the `[cors]` section instead? I’m not sure if `ACCESS_CONTROL_ALLOW_ORIGIN` still works.

Equivalent to `ACCESS_CONTROL_ALLOW_ORIGIN = *` should just be:

```auto
[cors]
ENABLED = true
#ALLOW_DOMAIN = * (this is default value so not need setting)

```

---

<div class="post-metadata">

**Author:** ![jimafisk](https://avatars.discourse-cdn.com/v4/letter/j/9e8a1a/32.png) [@jimafisk](https://forum.gitea.com/u/jimafisk)\
**Post date:** [January 27, 2023, 5:57pm UTC](https://forum.gitea.com/t/no-access-control-allow-origin-header-is-present-on-the-requested-resource/2636/4 "2023-01-27T17:57:42Z")

</div>

Thanks for the reply @jake! I thought that putting `ACCESS_CONTROL_ALLOW_ORIGIN` made more sense in the `[cors]` section than the `[repository]` section despite [the docs](https://docs.gitea.io/en-us/config-cheat-sheet/#repository-repository), so I had actually tried that, but without much luck.

I also already had the following in `custom/conf/app.ini` so I was surprised I was hitting this in the first place:

```auto
[cors]
ENABLED = true
ALLOW_DOMAIN = *

```

I’ve since deleted the test project that I was using when I ran into this, but I’ll follow up with more details if I can recreate the issue. Thank you for the help!

---

<div class="post-metadata">

**Author:** ![jimafisk](https://avatars.discourse-cdn.com/v4/letter/j/9e8a1a/32.png) [@jimafisk](https://forum.gitea.com/u/jimafisk)\
**Post date:** [May 17, 2023, 1:03pm UTC](https://forum.gitea.com/t/no-access-control-allow-origin-header-is-present-on-the-requested-resource/2636/5 "2023-05-17T13:03:27Z")

</div>

I’m still running into this unfortunately, has anyone else been able to set an ‘Access-Control-Allow-Origin’ header?

I originally thought my issue might have been the endpoint URL I was POSTing to was incorrect so it was returning a 404 page that wasn’t setting the appropriate headers. However, I can successful interact with the endpoints using a local REST client (Insomnia) and the header just doesn’t seem to be there. Any additional help would be greatly appreciated! Thank you!

---

<div class="post-metadata">

**Author:** ![wxiaoguang](https://sea2.discourse-cdn.com/flex020/user_avatar/forum.gitea.com/wxiaoguang/32/2280_2.png) [@wxiaoguang](https://forum.gitea.com/u/wxiaoguang)\
**Post date:** [May 21, 2023, 2:04am UTC](https://forum.gitea.com/t/no-access-control-allow-origin-header-is-present-on-the-requested-resource/2636/6 "2023-05-21T02:04:05Z")

</div>

Which URL are you visiting?

---

<div class="post-metadata">

**Author:** ![jimafisk](https://avatars.discourse-cdn.com/v4/letter/j/9e8a1a/32.png) [@jimafisk](https://forum.gitea.com/u/jimafisk)\
**Post date:** [May 22, 2023, 1:22am UTC](https://forum.gitea.com/t/no-access-control-allow-origin-header-is-present-on-the-requested-resource/2636/7 "2023-05-22T01:22:55Z")

</div>

Thanks for following up @wxiaoguang! I’m trying to POST to the `/repos/{owner}/{repo}/contents/{filepath}` endpoint ([Gitea API](https://try.gitea.io/api/swagger#/repository/repoCreateFile)). I can do this locally using [Insomnia](https://insomnia.rest/) but if I try to do it from the browser I get the following error in the console:

```auto
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.

```

When I check the headers in the response in Insomnia, I don’t see `Access-Control-Allow-Origin` no matter what changes I make to `custom/conf/app.ini`. I can manipulate other CORS options like `X_FRAME_OPTIONS` though.

---

<div class="post-metadata">

**Author:** ![jimafisk](https://avatars.discourse-cdn.com/v4/letter/j/9e8a1a/32.png) [@jimafisk](https://forum.gitea.com/u/jimafisk)\
**Post date:** [May 22, 2023, 2:50am UTC](https://forum.gitea.com/t/no-access-control-allow-origin-header-is-present-on-the-requested-resource/2636/8 "2023-05-22T02:50:28Z")

</div>

Sorry it looks like I _did_ have a typo in my endpoint URL. That was returning a 404 error without the `Access-Control-Allow-Origin` header as expected. As mentioned before, the only config needed in `custom/conf/app.ini` appears to be:

```auto
[cors]
ENABLED = true
ALLOW_DOMAIN = *

```

Thank you for the help and sorry for the confusion!

---

<div class="post-metadata">

**Author:** ![jimafisk](https://avatars.discourse-cdn.com/v4/letter/j/9e8a1a/32.png) [@jimafisk](https://forum.gitea.com/u/jimafisk)\
**Post date:** [May 29, 2023, 10:53pm UTC](https://forum.gitea.com/t/no-access-control-allow-origin-header-is-present-on-the-requested-resource/2636/9 "2023-05-29T22:53:15Z")

</div>

I also just want to note that after fixing the endpoint URL I could `POST` successfully, but `PUT` and `DELETE` would still 404. I thought these were enabled by default looking at the [docs](https://docs.gitea.io/en-us/administration/config-cheat-sheet/#cors-cors), but that doesn’t seem to be the case. In case it helps someone, you can enable these methods (and others) in `custom/conf/app.ini` like:

```auto
[cors]
METHODS: GET,HEAD,POST,PUT,PATCH,DELETE,OPTIONS

```
