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
  • u

    Unternoober

    05/20/2021, 2:10 PM
    the golang docs suggest handling CORS at the server level: https://supertokens.io/docs/go/usage/handling-cors I have different policies for various paths under the same server, and to date have been returning the Access-Control-* headers from within the handlers for each of those paths I'm just getting to where I'm incorporating the supertokens middleware on the backend ... and because it's inserted between the server and the path-handler, if the middleware hits an error the path-handler never has a chance to send the Access-Control-* headers so: when the middleware hits an error, the error is masked in the browser by a complaint about there being no CORS header in the response
  • u

    Unternoober

    05/20/2021, 2:11 PM
    I could do something awkward like .... add my own middleware to handle Access-Control, then supertokens' middleware, then my actual handler
  • u

    Unternoober

    05/20/2021, 2:11 PM
    but is there some more obvious pattern?
  • r

    rp

    05/20/2021, 2:13 PM
    > I could do something awkward like .... add my own middleware to handle Access-Control, then supertokens' middleware, then my actual handler This is the way I have seen in most projects, so this is what i'd recommend.
  • s

    sahil-shubham

    05/21/2021, 8:26 AM
    How can we have multiple domains (not sub-domains) as the websiteDomain and apiDomain in the appInfo? For CORS, I can pass an array containing the different domains as strings or regex. But passing an array doesn't work for the appInfo.
  • r

    rp

    05/21/2021, 8:27 AM
    Do you want to share a session across multiple domains that are not subdomains? Or something else?
  • r

    rp

    05/21/2021, 8:28 AM
    If not, you could use something like
    window.location.hostname
    to set the value of
    websiteDomain
  • s

    sahil-shubham

    05/21/2021, 8:28 AM
    Well, I have setup deploy previews for my pull requests which have a different domain and that too different for each PR. With this I also to allow production domain.
  • s

    sahil-shubham

    05/21/2021, 8:29 AM
    Oh, okay. I think I can check if the
    window.location.hostname
    passes the regex check, if yes then I would set
    websiteDomain
    as the
    window.location.hostname
  • r

    rp

    05/21/2021, 8:30 AM
    Yes, and if you are using nextjs, your apiDomain can also be that
  • s

    sahil-shubham

    05/21/2021, 8:30 AM
    Yep, understood. Thank you.
  • u

    user

    05/21/2021, 1:26 PM
    Hey I just started using SuperTokens but sadly i ran into an issue while using it with NextJS. I am currently at step 3 of the NextJS and already have serverless functions in this project (made with go). The app is started using
    yarn vercel dev
    and runs on localhost:3000

    https://catgirl.top/i/1107.png▾

  • r

    rp

    05/21/2021, 1:26 PM
    hey @User , unfortunately, we don't support go for login at the moment
  • r

    rp

    05/21/2021, 1:27 PM
    If you write your serverless functions using JS, then it would work fine
  • u

    user

    05/21/2021, 1:29 PM
    The login and all other supertokens related serverless functions are written in JS
  • r

    rp

    05/21/2021, 1:30 PM
    ahh i see.
  • r

    rp

    05/21/2021, 1:30 PM
    Can you should me your auth serverless function?
  • r

    rp

    05/21/2021, 1:31 PM
    Also, there is no api like /api/auth. You may want to query /api/auth/signin or something else that exists.. You can see the list of APIs here: https://github.com/supertokens/frontend-driver-interface/blob/master/v1.8.0.md
  • u

    user

    05/21/2021, 1:31 PM
    I am using the one provided here:
  • u

    user

    05/21/2021, 1:31 PM

    https://catgirl.top/i/23wh.png▾

  • r

    rp

    05/21/2021, 1:32 PM
    what does your backend and frontend config look like?
  • r

    rp

    05/21/2021, 1:32 PM
    i mean the appInfo object
  • u

    user

    05/21/2021, 1:33 PM
    its the one provided in this step of the guide.
  • r

    rp

    05/21/2021, 1:33 PM
    Have you set
    apiBasePath: "/api/auth/"
    in the appInfo?
  • u

    user

    05/21/2021, 1:35 PM
    js
    let appInfo = {
      // learn more about this on https://supertokens.io/docs/thirdparty/appinfo
      appName: 'SuperTokens Demo App', // TODO: Your app name
      websiteDomain: "http://localhost:3000", // TODO: Add your website domain
      apiDomain: "http://localhost:3000", // TODO: should be equal to `websiteDomain` in case using the `api` folder for APIs
      apiBasePath: "/api/auth/", // /api/auth/* will be where APIs like sign out, sign in will be exposed 
    }
    This is my current appInfo (i havent changed anything from the guide)
  • r

    rp

    05/21/2021, 1:36 PM
    this is really strange...
  • r

    rp

    05/21/2021, 1:36 PM
    can you print a console log in the auth serverless function to see if that get's called?
  • u

    user

    05/21/2021, 1:37 PM
    I have a feeling that this is a Vercel problem. I have already asked their support team about it since I also ran into an issue like this while using Auth0
  • r

    rp

    05/21/2021, 1:37 PM
    I see..
  • r

    rp

    05/21/2021, 1:38 PM
    does this help you: https://github.com/supertokens/supertokens-node/issues/118
Powered by Linen
Title
r

rp

05/21/2021, 1:38 PM
does this help you: https://github.com/supertokens/supertokens-node/issues/118
View count: 2