https://supertokens.com/ logo
Title
l

LKz

12/28/2022, 2:41 PM
Hi, thank you for an amazing work! I've use the Passwordless recipe with Ionic app and developer/user experience was amazing. Now I'm trying to figure out, if it is possible to use a single API and 2 frontend with different domain names? In my case ionic use localhost in hybrid app, but to publish it on the web I need another registered domain name.
r

rp

12/28/2022, 3:07 PM
Hey @LKz you can use env vars to determine if it’s local dev or not. And if it is, set websiteDomain to localhost
Is this what you were asking? Maybe I’m misunderstanding.
l

LKz

12/28/2022, 3:25 PM
Hi, ionic will use "localhost" for prod too (it will be served inside native app). That means in my case, I'll have - nodejs api with domain api.somedomain - ionic app with domain localhost - web app with domain app.somedomain All at the same time in a production environment. Not sure if it's possible to use single api for both front-end in this case.
r

rp

12/28/2022, 3:30 PM
Ahh right.
So this can be done. You should set the websiteDomain on the backend to point to your web app’s domain and also set cookieSameSite in session.init on the backend to have value of “none”
This means things like passwordless links will open in the web app. If you want it to open in ionic app for requests from ionic, then you should override the sendEmail function in emailDelivery config and change the domain in the magic link based on the request’s origin.
l

LKz

12/29/2022, 5:20 AM
Thanks! I'll give it a try