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

Access-Control-Allow-Headers in API #12424

Closed
2 of 7 tasks
24unix opened this issue Aug 4, 2020 · 0 comments · Fixed by #12446
Closed
2 of 7 tasks

Access-Control-Allow-Headers in API #12424

24unix opened this issue Aug 4, 2020 · 0 comments · Fixed by #12446
Labels
type/proposal The new feature has not been accepted yet but needs to be discussed first.

Comments

@24unix
Copy link

24unix commented Aug 4, 2020

  • Gitea version (or commit ref): v1.12 and HEAD branch
  • Git version: 2.20.1
  • Operating system: Debian Buster 10.4
  • Database (use [x]):
    • PostgreSQL
    • MySQL
    • MSSQL
    • SQLite
  • Can you reproduce the bug at https://try.gitea.io:
    • Yes (provide example URL)
    • No: Seems broken, throws 500 error
    • Not relevant
  • Log gist:

Description

I already postet some information here:
#6408

I try to give a summary.

I want to access the list of all commits in a given repo in a Vue app using axios.

My Gitea server works fine, accessing the info via curl works, even in Chrome I get the expected headers (see screenshot), but the cors settings prevent the Javascript, or especially axios to access the data.

Here are some background infos:
https://stackoverflow.com/questions/37897523/axios-get-access-to-response-header-fields

So, I need to tell Gitea to send X-Total in the Access-Control-Allow-Headers, I already glimpsed through the code, tried to change it myself, only to find out later that it was the part related to the general http stuff, not the API.

That is part of my code:

async fetchData() { this.isLoading = true; axios.get(https://git.24unix.net:3000/api/v1/repos/24unix.net/yyyy/commits?page=${this.currentPage}&limit=10`,
{
headers: {
Authorization: 'token ' + "bfebd3123cyyyyyyyyyyyyyyy34abe46f1a",
}
})
.then((response) => {
`

Response headers just contain the Content-Type.

Chrome receives the relevant headers:

image

@techknowlogick techknowlogick added the type/proposal The new feature has not been accepted yet but needs to be discussed first. label Aug 6, 2020
zeripath added a commit to zeripath/gitea that referenced this issue Aug 6, 2020
zeripath added a commit that referenced this issue Aug 13, 2020
Fix #12424

Signed-off-by: Andrew Thornton <[email protected]>
Co-authored-by: silverwind <[email protected]>
@go-gitea go-gitea locked and limited conversation to collaborators Nov 24, 2020
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
type/proposal The new feature has not been accepted yet but needs to be discussed first.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants