Hello -
I have an issue with netlify + vite + supertokens.
Basically apiUrl is not stripped from the URL passed to the api functions, making supertokens fail routing on the api side.
I can reproduce the issue locally using netlify dev that expose a 8888 port and both a web/api at 8910 and 8911 respectively.
Maybe an equivalent configuration is missing on the FE of netlify ? rewrite: (path) => path.replace(rwConfig.web.apiUrl, '') in @redwodjs/vite/src/index.ts
Would it be possible to provide more details of the problem youβre seeing here? As in:
what call is failing exactly
where are you calling the endpoint from?
maybe the relevant part from your netlify deployment
is it just a regular setup of supertokens (with yarn rw setupβ¦)?
Appreciate the debugging here, but not enough information to help! However I suspect itβs not related to the stripping of the apiUrl though, that may be more to do with the netlify CLI than your actual problem!
I also note the URLs you posted: http://localhost:8910/.netlify/functions/auth/jwt/jwks.json - so a jwt folder that nests a json file. I donβt believe this will work (without additional configuration), because Netlify will only pick up functions defined one level deep, for example:
Guess at solving the issue
Iβm not super familiar with supertokens (not used it myself yet) - but if this is just the standard setup, maybe youβll need to add a redirect to send all requests from .netlify/functions/auth/* to ./netlify/functions/auth
Iβm imagining the way it works is that it intercepts all requests to the /auth endpoint, and handles it internally.
Thanks for looking into this. It seems that indeed supertokens intercepts the auth calls and routes internally (including the jwks url).
All calls to /auth fails because supertokens expects the path to start with /auth and not /.netlify/functions/auth
I have the same issue on a fresh create-redwood + supertokens + netlify install. I use netlify dev to run locally the stack
The same issue happens on a netlify deploy or netlify dev
Temporary fix that works for me in the context of netlify deploy/dev is to replace apiBasePath config variable in the api supertokens init from /auth to /.netlify/functions/auth