https://supertokens.com/ logo
#support-questions
Title
# support-questions
e

EdwinN1337

06/27/2022, 9:37 AM
We are having an issue with our hosted api on vercel (nextjs)... The cookies are not set when requesting from a different origin (for example: capacitor://localhost)
r

rp

06/27/2022, 9:41 AM
The issue is that the sameSite was "lax" and not "none"
if you set the right websiteDOmain / apiDomain values (to reflect vercel URLs) then it should be fine
Maybe this will help
e

EdwinN1337

06/27/2022, 9:47 AM
I see, my bad! I've refactored the code, added FRONTEND_URL to our shared config. But it should be app specific
Copy code
js
export const appInfo = {
  appName: 'Lokalist Webshop',
  apiDomain: FRONTEND_URL,
  websiteDomain: FRONTEND_URL,
  apiBasePath: '/api/auth',
  websiteBasePath: '/auth',
}
error was pretty clear, sorry for disturbing 😦
In this case,
websiteDomain: process.env.VERCEL_URL,
Which i had before, but removed oops
r

rp

06/27/2022, 9:52 AM
sounds good! hope it works now
e

EdwinN1337

06/27/2022, 10:13 AM
One problem, not sure if I get it tho... our website domain on the apps (capacitor) depends on the platform
r

rp

06/27/2022, 10:14 AM
what do you mean by platform?
e

EdwinN1337

06/27/2022, 10:15 AM
for iOS the domain (origin) =
capacitor://localhost
android its
http://localhost
our web version it's
FRONTEND_URL
(the same i'm using on the backend)
r

rp

06/27/2022, 10:33 AM
So you want to set it to your web version
So for things like reset password emails, it will redirect the user to the web version - if that works for you
e

EdwinN1337

06/27/2022, 10:49 AM
Right, I've fixed the redirect already ;) Got it. Thanks!
r

rp

06/27/2022, 11:26 AM
👍
e

EdwinN1337

06/27/2022, 12:22 PM
@rp problem wasnt the lax
Copy code
js
export default function getCookieHandler(original: CookieHandlerInterface): CookieHandlerInterface {
  return {
    ...original,
    getCookie: async function () {
      const cookies = await getCookiesFromStorage()
      console.log({ cookies })
      return cookies
    },
    setCookie: async function (cookieString: string) {
      await setCookieToStorage(cookieString)
    },
  }
}
I didnt await the setCookieToStorage
r

rp

06/27/2022, 12:22 PM
oh right
does it work now?
e

EdwinN1337

06/27/2022, 12:22 PM
ye it works 😉
r

rp

06/27/2022, 12:22 PM
awesome
e

EdwinN1337

06/27/2022, 12:22 PM
pff was hard to figure out hehe, thanks anyways
r

rp

06/27/2022, 12:27 PM
yea fair enough
2 Views