I'm trying to set up Google OAuth2 on a website
I have a frontend React app made using create-react-app running on localhost:3000, and a backend Kotlin app using Ktor running on localhost:8080.
The following flow takes place:
- The user clicks a button on the React frontend, which makes a call to the backend using Fetch to localhost:8080/login.
- The backend responds with a redirect to the sign in with Google OAuth2 page.
- The frontend tries to follow this redirect.
- The request then fails with the error - [Error] 01:02:41.890 Origin null is not allowed by Access-Control-Allow-Origin. Status code: 200
Here is an image of the request, the redirect response and the following request:
As shown, the origin is null. From reading I understand this may be a privacy feature to protect the location of the backend, but how can this be fixed?
Tried manually setting the Origin header to wildcard or a domain, but neither resolved the issue.