is there a way to use two API endpoints? which are...
# general
j
is there a way to use two API endpoints? which are not hosted on the same domain?
r
hey @jj_9475
are they sub domains?
j
no, they are hosted on differnt platforms
r
then you will have to use header based auth
the apiDomain value should be the one which has the supertokens backend sdk integrated withit
for the other domain, you will have to add the access token to the auth header manually
and you can fetch the access token on the frontend using Session.getAccessToken()
j
you mean to use authorization bearer token ?
r
yea
j
well thanks will try this method.
one more question. How to verify the authorization token in the other end point? Do we have to check it manually or do we need to set up supertokens and check it via verify_session?
r
You could use the verify_session function. But for that, you have to setup supertokens sdk in that endpoint too
if you don't want to setup our SDK there, you can follow this page: https://supertokens.com/docs/session/common-customizations/sessions/with-jwt/jwt-verification
j
we have setup a sdk in that other server as well. but confused with initialization on api-domain and website-domain names.
r
both those should be the same as what you set on the other backend
j
i am unable to find Session.getAccessToken() on frontend . how can i access this token from frontend
r
which version of the frontend sdk are you using?
and which frontend sdk?
j
we are using react , supertokens-auth-react 0.18.0
r
oh i see. that's a much older version
it doesn't have that function in it
for your version, you would need to enable jwt on the backend, and then read that on the frontend via the access token payload.
search our discord for more info on how to do this please.
2 Views