https://supertokens.com/ logo
Docs
Join the conversationJoin Discord
Channels
community
contributing
general
github-activity
info
introductions
new-releases
random
security
support-questions
welcome-0xdelusion
welcome-aj-ya
welcome-aleksandrc
welcome-alpinjs
welcome-amberlamps1
welcome-andrew-rodriguez
welcome-ankit-choudhary
welcome-anthony-stod-custodio
welcome-call-in
welcome-chwalbox
welcome-claybiokiller
welcome-co7e
welcome-cosmoecwsa
welcome-devdag
welcome-dinso
welcome-drebotelho
welcome-elio
welcome-ernest
welcome-foxbarrington
welcome-fromscratch
welcome-galto4ir
welcome-goetzum
welcome-hay-kot
welcome-himanshu-kukreja
welcome-hossambarakat
welcome-ichikawakazuto
welcome-jahir9991
welcome-jamesl
welcome-jerry123424
welcome-john-oliver
welcome-jonas-alexanderson
welcome-jxyz
welcome-kelvinwop
welcome-kraz
welcome-lancekey
welcome-leoo
welcome-lukeacollins
welcome-m-j-mon
welcome-malik-khoja
welcome-marco
welcome-mardadi
welcome-meshguy
welcome-metamorph
welcome-mike-tectu
welcome-mirzok
welcome-mozomig
welcome-naberyou66_
welcome-nacer
welcome-namratha
welcome-naveenkumar
welcome-nightlight
welcome-nischith
welcome-notankit
welcome-olawumi
welcome-pavan-kumar-reddy-n
welcome-pineappaul
welcome-poothebear
welcome-rick
welcome-samuel-qosenergy
welcome-samuelstroschein
welcome-shubhamgoel23
welcome-shubhamkaushal
welcome-sidebar
welcome-surajsli
welcome-suyash_
welcome-syntaxerror
welcome-tauno
welcome-tauno
welcome-tawnoz
welcome-teclali
welcome-tls
welcome-turbosepp
welcome-vikram_shadow
welcome-yann
Powered by Linen
support-questions
  • g

    gusfune

    04/29/2021, 2:19 PM
    Thanks! Will test now. In case of nextJS, do I need to add the same recipe for node-js or only on react will do?
  • r

    rp

    04/29/2021, 2:21 PM
    you can continue using the same recipe you are using right now
  • r

    rp

    04/29/2021, 2:21 PM
    Have a look at this link: https://supertokens.io/recipe-redirect?to=/common-customizations/sessions/share-sessions-across-sub-domains You can ignore the previous one..
  • g

    gusfune

    04/29/2021, 3:52 PM
    I have tested here and put live, but it didn't work. When I go to the subdomain it asks for a new login.
  • r

    rp

    04/29/2021, 4:00 PM
    Can you share the frontend config + an example of the a sub domain being used?
  • g

    gusfune

    04/29/2021, 4:02 PM
    Front-end config:
    export const frontendConfig = () => {
      return {
        useReactRouterDom: false,
        appInfo,
        recipeList: [
          Session.init({
            sessionScope: ".offscript.io",
          }),
          ThirdPartyEmailPasswordReact.init({
            signInAndUpFeature: {
              providers: [
                ThirdPartyEmailPasswordReact.Google.init(),
                ThirdPartyEmailPasswordReact.Facebook.init(),
              ],
          }),
          SessionReact.init(),
        ],
      }
    }
    Also appinfo is:
    const appInfo = {
      appName: "Off Script",
      apiDomain: websiteDomain,
      websiteDomain,
      apiBasePath: "/api/auth/",
    }
    WebsiteDomain is
    my.offscript.io
    and
    offscript.io
    according to the domain.
  • r

    rp

    04/29/2021, 4:04 PM
    set the websiteDOmain to always be
    offscript.io
  • g

    gusfune

    04/29/2021, 4:22 PM
    when I did that, the subdomains could not login, that's why I kept different. It threw a CORS error
  • r

    rp

    04/29/2021, 4:22 PM
    Ah. You should keep it to offscript.io, and what the CORS error?
  • g

    gusfune

    04/29/2021, 4:35 PM
    Let me replicate here from the test environment as this is not live for now
  • g

    gusfune

    04/29/2021, 4:35 PM
    Here is one saved from before:
    Cross-Origin Request Blocked: The Same Origin Policy disallows reading the remote resource at https://my.offscript.io/api/auth/signin. (Reason: CORS request did not succeed).
  • r

    rp

    04/29/2021, 4:37 PM
    So if you change websiteDOmain to
    offscript.io
    , the API call will go to
    https://offscript.io/api/auth/signin
    . The login screen is shown on
    offscript.io
    only right?
  • g

    gusfune

    04/29/2021, 4:40 PM
    The API call goes to the subdomain in this case, and the login screen is shown in the subdomain as well. Is that the resason? We can only login/call in one place?
  • r

    rp

    04/29/2021, 4:48 PM
    Ahh. ok. I thought the login screen is only on offscript.io
  • r

    rp

    04/29/2021, 4:49 PM
    so is it true that you can login with offscript.io & access offscript.io and my.offscript.io AND You can login via my.offscript.io and get access to offscript.io and my.offscript.io?
  • r

    rp

    04/29/2021, 4:49 PM
    or am i mis understanding the scenario?
  • g

    gusfune

    04/29/2021, 4:51 PM
    Yes, that would be the ideal scenario!
  • r

    rp

    04/29/2021, 4:51 PM
    ok wow.. i will have to think about that. give me sometime please.
  • r

    rp

    04/29/2021, 4:51 PM
    may require an additional param change from our side.
  • r

    rp

    04/29/2021, 4:52 PM
    Why do you have this scenario though - why not make all users just log in via offscript.io?
  • g

    gusfune

    04/29/2021, 4:54 PM
    Basically because the home page of the subdomains redirect the user to
    /auth/
    as they are private pages. But I can try to redirect them to the main website and then back, I'll give it a try.
  • g

    gusfune

    04/29/2021, 5:15 PM
    Ok, in a few moments testing it out
  • r

    rp

    04/29/2021, 5:20 PM
    So the root problem is that our redirection post login ignores the domain from where the user came from. We ignore it cause of a phishing attacks where an attacker can form a malicious link redirecting a user back to their login. But perhaps we can change it to not ignore the domain if the top level domain of the source is the same - this way, it would just work for you.. what do you think of this?
  • g

    gusfune

    04/29/2021, 5:25 PM
    Actually, I managed to make it work. I did what you said, but in the subdomains I redirect the user to the main page login.
  • g

    gusfune

    04/29/2021, 5:26 PM
    With a /redirect parameter in the URL back
  • g

    gusfune

    04/29/2021, 5:26 PM
    that did the trick
  • g

    gusfune

    04/29/2021, 5:26 PM
    Thanks a lot!
  • r

    rp

    04/29/2021, 5:32 PM
    Cool! So is there any change u require from our side?
  • g

    gusfune

    04/29/2021, 5:52 PM
    Actually the verify thing might be necessary, doing more tests, it seems to work in one browser, but not safari
  • g

    gusfune

    04/29/2021, 5:52 PM
    session doesn't stick
Powered by Linen
Title
g

gusfune

04/29/2021, 5:52 PM
session doesn't stick
View count: 1