Hi, i'm having issues with logout in my production...
# ask-a-descoper
d
Hi, i'm having issues with logout in my production application; i have tested in 2 similar environments (demo and prod). when i look at the call to the API
/v1/auth/logout
the main difference i see is in the set-cookie header in one env (the one that is working as expected) i see both
set-cookie
for DS & DSR with the domain but than when i look in the prod env set cookie for DS the domain is empty and for DSR i see the domain. so the DSR cookie is cleared but the DS is not cleared and the user can't logout. what can i do to troubleshoot the issue? some additional info, refresh token in both is set to "Manage in cookies" and "Session token" is set to "Manage in response body". cookie policy is Lax
r
Hi @Dror Rash Based on your configuration where the refresh token is managed in cookies but the session token is in the response body, the DS cookie shouldn't normally be set by Descope's backend. However, if you're using a client SDK with
sessionTokenViaCookie
enabled, the SDK itself sets the DS cookie. The domain mismatch you're seeing suggests a custom domain configuration issue in your prod environment. When using cookie-based tokens, Descope requires proper custom domain setup. Troubleshooting steps: 1. Verify custom domain configuration - Check that your prod environment's custom domain setting matches your demo environment. The custom domain should be set to something like
app.example.com
, with a CNAME record for
auth.app.example.com
pointing to
cname.descope.com
(US) or
cname.euc1.descope.com
(EU). 2. Check SDK initialization - If you're using
sessionTokenViaCookie
in your SDK, verify the domain configuration. You can customize the cookie domain by passing
sessionTokenViaCookie: {domain: 'your-domain.com'}
to ensure consistency. 3. Cookie name conflicts - If running multiple Descope projects on the same domain, ensure you're using unique cookie names via the
cookieName
option to avoid conflicts. 4. Manual cookie cleanup - After calling logout, you must invalidate or remove any cookies you created. If providing an
http.ResponseWriter
(backend) or using the SDK's logout function with proper configuration, this should happen automatically. The key issue is likely that your prod environment's domain configuration differs from demo, causing the DS cookie to be set without a proper domain attribute, preventing it from being cleared on logout. Docs: https://github.com/descope/descope-js/blob/main/packages/sdks/web-js-sdk/README.md https://github.com/descope/descope-js/blob/main/packages/sdks/react-sdk/README.md https://docs.descope.com/management/project-settings/refresh-token-storage https://docs.descope.com/authorization/session-management/session-validation/backend
d
thanks for the quick reply, i will look into these points
🙌 1
hi, @Rahul Rijhwani looks like
sessionTokenViaCookie
doesn't have the domain property in the interface this is what is see:
Copy code
interface IAuthProviderProps {
    projectId: string;
    baseUrl?: string;
    baseStaticUrl?: string;
    persistTokens?: boolean;
    sessionTokenViaCookie?: boolean | {
        sameSite: SameSite;
    };
    storeLastAuthenticatedUser?: boolean;
    keepLastAuthenticatedUserAfterLogout?: boolean;
    refreshCookieName?: string;
    children?: React.ReactNode;
}
Copy code
"name": "@descope/react-sdk",
"version": "2.7.1",
r
Let me check
Based on your configuration where the session token is managed in the response body, the issue is specifically with the DS cookie domain during logout. Since you have: • Refresh token: "Manage in cookies" • Session token: "Manage in response body" • Cookie policy: Lax The key troubleshooting step is the
baseUrl
parameter in your SDK initialization. The
baseUrl
is your custom domain that must be configured to manage token response in cookies. This ensures every request to Descope goes through your custom domain.
Copy code
<AuthProvider
    projectId="__ProjectID__"
    baseUrl="https://auth.app.example.com"
    persistTokens={true}
    sessionTokenViaCookie={false}
    storeLastAuthenticatedUser={true}
    keepLastAuthenticatedUserAfterLogout={false}
>
  <App />
</AuthProvider>
Key troubleshooting steps: 1. Compare the
baseUrl
configuration between demo and prod environments 2. Verify your custom domain is properly configured in both environments 3. Check that the domain in your Descope project settings matches the
baseUrl
in both environments 4. Ensure both environments use the same cookie domain configuration in the Session Management settings Check this doc: https://docs.descope.com/security-best-practices/session-token-storage https://docs.descope.com/authorization/session-management/session-validation/client https://docs.descope.com/client-sdk/initialize-sdk
d
@Rahul Rijhwani thanks I'll check this