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

    michaelzhuk

    05/11/2021, 12:03 PM
    I'm not sure... In our case website/iframe domains are different but they're both using https
  • r

    rp

    05/11/2021, 12:04 PM
    yes that's in production. However in dev, they will be http correct?
  • m

    michaelzhuk

    05/11/2021, 12:05 PM
    I'm using ngrok for development, so it's https too
  • r

    rp

    05/11/2021, 12:07 PM
    oooo! understood.
  • r

    rp

    05/11/2021, 12:07 PM
    Will try and fix this today.
  • r

    rp

    05/11/2021, 12:18 PM
    @User Can you please do the following and then try to use the iframe and see if it works: - Go to supertokens-website folder inside node_modules - In there, open lib > build > fetch.js - For each of the following lines, add
    samesite=none
    at the end of the string (before the closing "). For example, if a line is
    ID_REFRESH_TOKEN_NAME + "=" + cookieVal + ";expires=" + expires + ";path=/";
    , then change it to
    ID_REFRESH_TOKEN_NAME + "=" + cookieVal + ";expires=" + expires + ";path=/;samesite=none";
    Lines: - https://github.com/supertokens/supertokens-website/blob/master/lib/build/fetch.js#L1138 - https://github.com/supertokens/supertokens-website/blob/master/lib/build/fetch.js#L1141 - https://github.com/supertokens/supertokens-website/blob/master/lib/build/fetch.js#L1221 - https://github.com/supertokens/supertokens-website/blob/master/lib/build/fetch.js#L1224 - https://github.com/supertokens/supertokens-website/blob/master/lib/build/fetch.js#L1318 - https://github.com/supertokens/supertokens-website/blob/master/lib/build/fetch.js#L1321
  • r

    rp

    05/11/2021, 12:20 PM
    Also, you may want to set
    antiCsrf
    value in the backend (Session.init) to
    "VIA_TOKEN"
    . Since you will be using an iframe.
  • m

    michaelzhuk

    05/11/2021, 12:33 PM
    Yes. I'll get back in a couple of hours with the result of this.
  • r

    rp

    05/11/2021, 1:03 PM
    thanks!
  • r

    rp

    05/11/2021, 3:40 PM
    @User instead of trying the above, please try the following: - Update your supertokens-auth-react dependency to
    supertokens/supertokens-auth-react#0.13
    - Delete yarn.lock file, and run
    yarn install
    . This should install new versions of
    supertokens-auth-react
    (0.13.0) and
    supertokens-website
    (7.1.0). - In the frontend config, change
    SessionReact.init()
    to
    SessionReact.init({ isInIframe: true })
    . - In backend config, change
    SessionNode.init({ cookieSameSite: "none" })
    to
    SessionNode.init({ cookieSameSite: "none", antiCsrf: "VIA_TOKEN" })
    - Try logging in via the iframe, and it should work.
  • h

    Healsies

    05/12/2021, 4:14 AM
    I'm farting about with the supertokens context in react, and i'm finding the variables im getting from useSessionContext() aren't updating when i log in or log out. I am misunderstanding contexts or is this supposed to happen automatically?
  • r

    rp

    05/12/2021, 4:43 AM
    @Healsies yea that’s an open issue at the moment. Have you wrapped your entire app with the auth wrapper? Or just individual routes that need auth to be accessed?
  • r

    rp

    05/12/2021, 4:44 AM
    If you use them with individual routes that need auth to be accessed, it will work just fine (since logged in status in those routes won’t change).
  • r

    rp

    05/12/2021, 4:46 AM
    this is the issue to watch for this feature: https://github.com/supertokens/supertokens-auth-react/issues/228
  • h

    Healsies

    05/12/2021, 4:46 AM
    Thanks for the quick reply! Ill check that out
  • h

    Healsies

    05/12/2021, 4:49 AM
    Great library by the way πŸ’Œ
  • r

    rp

    05/12/2021, 4:50 AM
    Thanks! πŸ™Œ
  • r

    rp

    05/12/2021, 4:55 AM
    What made you interested if you dont mind me asking? Seems like you joined our Discord a long time ago?
  • h

    Healsies

    05/12/2021, 4:57 AM
    Im an amateur dev. I was trying to learn how JWT's worked and i came across your website and saw the breakdowns (which were awesome), and the library. So i bookmarked for it use next time i had to write an app
  • m

    michaelzhuk

    05/12/2021, 5:00 AM
    After these changes auth stopped working at all. After login it doesn't set any cookies/localstorage and I'm redirected back to login screen
  • m

    michaelzhuk

    05/12/2021, 5:01 AM
    Same even outside iframe
  • r

    rp

    05/12/2021, 5:02 AM
    @User the change that was made is that we set the cookie's sameSite to
    none
    .
  • r

    rp

    05/12/2021, 5:02 AM
    which would only be applied if the domain is https
  • r

    rp

    05/12/2021, 5:03 AM
    if the domain is https, and cookies are still not being applied, do you see any error in the console explaining why they are not getting set?
  • m

    michaelzhuk

    05/12/2021, 5:07 AM
    First it tries to send a /refresh requests with no cookies (as I'm logged out) which returns 401 - which is fine
  • m

    michaelzhuk

    05/12/2021, 5:07 AM
    message has been deleted
  • m

    michaelzhuk

    05/12/2021, 5:08 AM
    Then it sends /signin request and gets cookies in response
  • m

    michaelzhuk

    05/12/2021, 5:08 AM
    message has been deleted
  • m

    michaelzhuk

    05/12/2021, 5:08 AM
    This also looks right
  • m

    michaelzhuk

    05/12/2021, 5:09 AM
    But then it sends /refresh request again with cookies but the server responds without cookies (server clears cookies)
Powered by Linen
Title
m

michaelzhuk

05/12/2021, 5:09 AM
But then it sends /refresh request again with cookies but the server responds without cookies (server clears cookies)
View count: 1