Web API - Invalid origin

Following the https://docs.sentry.io/api/, I’m trying to fetch stats for a particular team as described at https://docs.sentry.io/api/teams/get-team-stats/

On hitting the endpoint, I’m getting 400 BAD REQUEST , with the response as: Invalid origin: http://localhost:8001

Code snippet:

    fetch( fetchURL,{
        method: 'GET',
        headers: {
            'Content-Type': 'application/json',
            'Authorization': 'Bearer <token>'
        },
    })
1 Like

You need to configure allowed domains / origins within your token settings.

@zeeg hello!
I faced the same problem.
In project “Allowed Domains” is “*”
Example with curl:

curl -H 'Authorization: Bearer xxxxxxxxxx' -H "Origin: https://mydomain.com" http://localhost:9000/api/0/projects/sentry/external-sdk/
 "Invalid origin: https://mydomain.com"

I don’t understand how to configure allowed domains / origins within token settings.
Could you explain?

1 Like

I have the same problem.

Origin: http://localhost:8000
“Invalid origin: http://localhost:8000

I just want to retrieve the projects (base URL + /api/0/projects/) in my application and it doesn’t work from my web browser, I tried the same from postman and it works. But when I add Origin to the headers, it doesn’t seem to work except setting this to ‘null’.

Allowed Domains in my project settings is set to ‘*’.

Are there any other settings that need to be set or parameters/headers that we should add to the request?

I have seen a lot of closed items on this although a lot of people still seem to have these problems.