React SPA + Go Regular Web App for callback

I created an API (my audience) and now I want to authenticate my react SPA client.

I created two applications: a SPA, and regular web app

I am trying to have my SPA callback to a Go web app so that I can create a user in my own database for the email used to sign up.

Here’s a simple way to describe the flow locally, running the react SPA on port 3000 and go service on 8080:

react app has a login link to localhost:8080/login, which goes to 8080/callback which redirects back to localhost:3000/ . while on the Go side I can create the user in my database, and I have the state and code, and accesstoken and id token.

When I redirect from the Go side to the SPA again, is there some way I can set some cookies or something so the auth0 spa js can see that I am authenticated?

1 Like

Hi @kdm Welcome back

I think the scenario you are describing is better served with SPA + API architecture. You can have a React SPA front end and a GO web api (not regular webapp). You an authenticate users from front end using auth0-spa.js and then get an accessToken. Once you have an accessToken, you can send that to your Go api to create a user in your own database. This is precisely what we describe in here Single-Page Applications (SPA) with API I think creating a user in your db during login callback is unnecessary complexity and doesn’t fit the usual OIDC flow.