I am getting a weird issue on refresh. The auto refresh works on get requests but not put/post reque...
c
I am getting a weird issue on refresh. The auto refresh works on get requests but not put/post requests.
r
Hey! Are you using axios on the frontend?
c
Yeap, that's why the get requests are refreshed
r
Have you added the supertoeks axios interceptors to it?
c
Yeap
const myAxios = axios.create({ baseURL: process.env.NEXT_PUBLIC_API_DATA_URL, withCredentials: true, }); Session.addAxiosInterceptors(myAxios);
r
Hmm. Can you enable frontend and backend debug logs whilst making the request in which you expect the refresh to be called (but itโ€™s not being called)
c
Frontend logs:
com.supertokens {t: "2022-09-23T18:59:11.515Z", message: "responseErrorInterceptor: called", supertokens-website-ver: "13.1.0"} logger.js?12ee:31 com.supertokens {t: "2022-09-23T18:59:11.515Z", message: "responseErrorInterceptor: Status code is: 401", supertokens-website-ver: "13.1.0"} logger.js?12ee:31 com.supertokens {t: "2022-09-23T18:59:11.516Z", message: "doRequest: called", supertokens-website-ver: "13.1.0"} logger.js?12ee:31 com.supertokens {t: "2022-09-23T18:59:11.516Z", message: "shouldDoInterceptionBasedOnUrl: toCheckUrl: http://localhost:8000/users apiDomain: http://localhost:8001 cookiDomain: undefined", supertokens-website-ver: "13.1.0"} logger.js?12ee:31 com.supertokens {t: "2022-09-23T18:59:11.516Z", message: "doRequest: Value of doNotDoInterception: true", supertokens-website-ver: "13.1.0"} logger.js?12ee:31 com.supertokens {t: "2022-09-23T18:59:11.516Z", message: "doRequest: Returning without interception", supertokens-website-ver: "13.1.0"}
Backend logs:
com.supertokens {"t": "2022-09-23T18:59:50.887Z", "sdkVer": "0.11.0", "message": "middleware: Started", "file": "supertokens.py:536"} com.supertokens {"t": "2022-09-23T18:59:50.887Z", "sdkVer": "0.11.0", "message": "middleware: Not handling because request path did not start with config path. Request path: /users", "file": "supertokens.py:543"} com.supertokens {"t": "2022-09-23T18:59:50.888Z", "sdkVer": "0.11.0", "message": "getSession: Started", "file": "recipe/session/recipe_implementation.py:241"} com.supertokens {"t": "2022-09-23T18:59:50.888Z", "sdkVer": "0.11.0", "message": "getSession: rid in header: False", "file": "recipe/session/recipe_implementation.py:243"} com.supertokens {"t": "2022-09-23T18:59:50.888Z", "sdkVer": "0.11.0", "message": "getSession: request method: PUT", "file": "recipe/session/recipe_implementation.py:246"} com.supertokens {"t": "2022-09-23T18:59:50.888Z", "sdkVer": "0.11.0", "message": "getSession: Returning try refresh token because access token from cookies is undefined", "file": "recipe/session/recipe_implementation.py:269"}
com.supertokens {"t": "2022-09-23T18:59:50.889Z", "sdkVer": "0.11.0", "message": "errorHandler: Started", "file": "supertokens.py:610"} com.supertokens {"t": "2022-09-23T18:59:50.889Z", "sdkVer": "0.11.0", "message": "errorHandler: Error is from SuperTokens recipe. Message: Access token has expired. Please call the refresh API", "file": "supertokens.py:611"} com.supertokens {"t": "2022-09-23T18:59:50.889Z", "sdkVer": "0.11.0", "message": "errorHandler: Checking recipe for match: session", "file": "supertokens.py:622"} com.supertokens {"t": "2022-09-23T18:59:50.889Z", "sdkVer": "0.11.0", "message": "errorHandler: Matched with recipeID: session", "file": "supertokens.py:628"} com.supertokens {"t": "2022-09-23T18:59:50.889Z", "sdkVer": "0.11.0", "message": "errorHandler: returning TRY_REFRESH_TOKEN", "file": "recipe/session/recipe.py:245"} com.supertokens {"t": "2022-09-23T18:59:50.889Z", "sdkVer": "0.11.0", "message": "Sending response to client with status code: 401", "file": "utils.py:134"}
tried fetch and it fails too
Spend the whole day but figured it out ๐Ÿ˜† cookie_domain needs to be set if you're using different backend apps/apis. In my case, I had a fastapi backend service for data related requests and another fastapi backend auth service.
r
Ahhh I see. Cool
By the way, this setting needs to go on the frontend as well
c
Yeap did that