Hey I am trying to deploy our app via Digital Ocea...
# support-questions
m
Hey I am trying to deploy our app via Digital Ocean (with supertokens - managed service) but I am getting a 404 error when accessing the login page / signup page. I am using the same domain for the front end (React) and the API. However, the api endpoint is at "/api". I think it might have something to do with the supertokens config in my code?
r
Hey I am trying to deploy our app via Digital Ocean (with supertokens - managed service) but I am getting a 404 error when accessing the login page / signup page. I am using the same domain for the front end (React) and the API. However, the api endpoint is at "/api". I think it might have something to do with the supertokens config in my code?
What’s your frontend config? The default login page is /auth on the frontend
m
this is the supertokens config
in the front end
r
Right yea. So you should visit websiteDomain/auth
To see the login screen
If that’s where your react app is hosted
m
yep, and that works ( meaning, I can see the login form / or signup form..). But when I try to use it, it throws errors.
r
Can you enable debug log and show me the output?
m
then getting 404 in the inspector
r
Right. Have you integrated our SDK with your backend api layer?
Node / golang or python
m
Yes. Node. Emailpassword recipe
r
Can you enable debug logs and show the output?
See the troubleshooting section
m
ok. can that be done even when using the managed service?
r
Yes. Checkout the troubleshooting section 🙂
m
[2022-04-29 14:27:36] 2022-04-29T14:27:36.790Z com.supertokens {t: "2022-04-29T14:27:36.790Z", message: "getSession: Started", file: "/workspace/node_modules/supertokens-node/lib/build/recipe/session/recipeImplementation.js:142:26" sdkVer: "9.1.2"} [2022-04-29 14:27:36] [2022-04-29 14:27:36] 2022-04-29T14:27:36.790Z com.supertokens {t: "2022-04-29T14:27:36.790Z", message: "getSession: rid in header: true", file: "/workspace/node_modules/supertokens-node/lib/build/recipe/session/recipeImplementation.js:153:26" sdkVer: "9.1.2"} [2022-04-29 14:27:36] [2022-04-29 14:27:36] 2022-04-29T14:27:36.791Z com.supertokens {t: "2022-04-29T14:27:36.791Z", message: "getSession: request method: post", file: "/workspace/node_modules/supertokens-node/lib/build/recipe/session/recipeImplementation.js:154:26" sdkVer: "9.1.2"} [2022-04-29 14:27:36] [2022-04-29 14:27:36] 2022-04-29T14:27:36.791Z com.supertokens {t: "2022-04-29T14:27:36.791Z", message: "getSession: returning undefined because idRefreshToken is undefined and sessionRequired is false", file: "/workspace/node_modules/supertokens-node/lib/build/recipe/session/recipeImplementation.js:161:34" sdkVer: "9.1.2"} [2022-04-29 14:27:36] [2022-04-29 14:27:36] 2022-04-29T14:27:36.792Z com.supertokens {t: "2022-04-29T14:27:36.792Z", message: "middleware: Started", file: "/workspace/node_modules/supertokens-node/lib/build/supertokens.js:158:26" sdkVer: "9.1.2"} [2022-04-29 14:27:36] [2022-04-29 14:27:36] 2022-04-29T14:27:36.792Z com.supertokens {t: "2022-04-29T14:27:36.792Z", message: "middleware: Not handling because request path did not start with config path. Request path: /session/refresh", file: "/workspace/node_modules/supertokens-node/lib/build/supertokens.js:165:30" sdkVer: "9.1.2"}
so this is the first part of logs i see when visiting the signin form
r
Can you please format it correctly?
m
yeah sorry ;D just added to a text file
r
So it seems that the cookies are not getting sent
Please go through the list above and check if any of the above reasons is why it’s not working
m
ok will do and let you know
thanks
Did some experiments but unfortunately still having problems 😦 - locally it all works, but in prod it keeps trying to create a session and failing to do so. No cookie is set in the browser and the SDK (debug mode) logs
2022-04-30T13:16:36.089Z com.supertokens {t: "2022-04-30T13:16:36.089Z", message: "getSession: returning undefined because idRefreshToken is undefined and sessionRequired is false", file: "/workspace/node_modules/supertokens-node/lib/build/recipe/session/recipeImplementation.js:161:34" sdkVer: "9.1.2"}
r
What’s the output of the sign in API?
The response headers and status code
m
this is what I see
r
Can you enable debug logging and show me the output?
m
when I land on the sign in form
r
Also, you said this works all fine in development mode?
m
yes in dev all good. I can connect, and it seems the tokens are generated properly and I get a successful redirect to the app
r
Hmm.
Send over the debug logs for this env where you are getting 404s
m
these are the logs from the SDK ( the last batch, since it is firing them like crazy while I am on the sign in page ahah )
r
What’s is your apiBasePath?
Or if you can send the logs when the process starts
That will help
m
logs from SDK when the server startup
r
Right. On the backend, you have set apiBasePath to /api/auth
m
this test production app is hosted at alpha.hyperlane.app while the API is the same domain but routed at
/api
r
On the frontend, you need to do the same
Oh. Ok. So the routing to /api happens on its own? By some proxy or a gateway?
So on the frontend you need to set the apiBasePath to /api/auth for this environment
m
mmm I think it is enabled via the hosting provider (Digital Ocean App Platform) as you can set up HTTP Request routes that a specific component can listen to (this case, the server)
r
See this
m
mm just checked but I think it is set up correctly?
r
This is on the frontend?
m
ah damn.. no backend
sorry one sec
r
Yup…
m
this is ... sorry bit messy
r
I don’t think process.env exists on the frontend
Can you log the values and see what it’s setting it to?
m
mm I have not done that part, let me ask
still waiting sorry, but from my logs on a built version of the React App (CRA)
r
Yeaaa. That should be /api/auth
m
mmm ok! let me rebuild everything and try again. Will keep uou posted! thanks so much!
Hey! So i finally managed to get it to work. So, the react app was actually fine, since the Vars were already applied correctly even with
process.env
(since they get included in the build). However, I had to change in the backend, the supertokens config in order to have API_BASE_PATH to be just
/auth
(while before both the front end and back end were
/api/auth
). So now the api base path in the front end is:
api/auth
while on the backend is just
/auth
. I guess before it was not working because the ST middleware was not catching the route properly so it kept trying to create a session?
Locally I guess it was working fine since I am just using the
localhost:3000
and
localhost:9000
for front and back respectively, while in Prod I am using the pattern
mywebsite.com
for the client and
mywebsite.com/api
for the server / Node
r
Hmm. You would need to set apiGatewayPath to /api then too
r
Yes
m
so you are suggesting the apiGatewayPath to the backend config ?
* to add
r
Yes.
That’s assuming that the backend code doesn’t see the “/api” part of the path. Depends on how you have setup the routing
7 Views