Configuring CNAME and Managing Sessions in Cookies


This guide will cover the end-to-end configuration necessary for configuring Descope to manage sessions in cookies by configuring a custom CNAME for your Descope project.

Note: Configuring a Custom Domain is a pro-tier feature. Learn more about upgrading your tier within our pricing overview.

Descope recommends storing your refresh tokens in cookies rather than within browser local storage. Keeping the refresh token in cookies is essential because it will help mitigate the risk of XSS (Cross-site-scripting) attacks since tokens in local storage are accessible via JavaScript. Descope uses httpOnly cookies in order to make the refresh token inaccessible to JavaScript, protecting your users from XSS and other browser-based attacks. Descope cookies are also sameSite=strict, so they are only sent in a first-party context, ensuring 3rd party websites cannot impersonate/hijack the user with a CSRF attack.

By default, your Descope project is configured to manage tokens in the HTTP response body; while this allows for a quick start at development, it is highly recommended to handle tokens in cookies for the above mentioned reasons.

Due to the nature of sameSite=strict, the domain used for the cookie must be a subdomain of your website, requiring you to configure a DNS setting for your website to allow using Descope API with your domain.

The sameSite and domain configurations are covered within this knowledge base guide.

Configure Custom CNAME

This section assumes you are not sharing the cookie with multiple subdomains. This guide is still applicable; however, the record will differ; for more information, see the section for Sharing Cookies Across multiple Subdomains. For this guide, the application lives at the domain

Create a DNS Record

Within your DNS settings for your host, create a DNS record for, which points to

  • Record Name:
  • Type: CNAME
  • TTL: Keep as default
  • Record Data/Value:

Descope custom domain cname host record.

Configure App URL

Within the Project Settings, under General, enter your app URL ex:

Descope configure custom domain cname within Descope project.

Configure Custom Domain

After adding the App URL, you will see the Configure Custom Domain section. Here you will click the Add button to add the Custom Domain to this project, for this example, it is This should match the configured DNS Record you created within your application.

Descope configure custom domain cname within Descope project.

Verify Domain configuration

Once the domain has been added, you will see Custom domain is pending verification under the domain. Periodically click the Refresh button until you see Setup complete.

The Descope console will also provide you with code snippets to use within your frontend to set the base URL to the configured custom domain, this will be used in the next step.

Descope configure custom domain cname within Descope project.

Configure Project to Manage Tokens in Cookies

Within the Project Settings, under Session management, select Manage in Cookies, then select the configured domain from the Cookie Domain dropdown. Select Strict from the Cookie Policy dropdown, then save the configuration.

Descope configure custom domain cname within Descope project.

Update the Base URL within Your Code

Within your code, use the record's base URL configured in step 1,, when utilizing the Descope Frontend SDKs or flows.

Here are some examples of configuring the base URL when initializing the client SDK.

<AuthProvider projectId='__ProjectID__' baseUrl=''>
<descope-wc project-id="__ProjectID__" base-url="" flow-id="sign-up-or-in"></descope-wc>
<AuthProvider projectId='__ProjectID__' baseUrl=''>

Test Cookie Storage

Test your Descope login flow. The DS, which is the Descope Session JWT, will be stored within the local storage, and the DSR, which is the Descope Session Refresh JWT will be stored under cookies for

For testing cookies within a local environment, see this knowledge base guide.

Using Custom Domains for OAuth Applications

Once you have configured the CNAME within your environment, you can utilize the custom domain within the OAuth applications when using your account. Based on the example above, within the configuration for the OAuth application, you will configure the custom domain with as shown in the below screenshot.

Descope custom domain for OAuth.

Sharing Cookies Across multiple Subdomains

The configuration is slightly different if you’d like to share cookies across multiple subdomains. When configuring the DNS record for this use case, the record name will be

Then within the Descope console, the Custom domain will be instead of within the project configuration, as you need to set the cookie at the topmost level of the domain.


Below covers an example of configuring the CNAME and cookie settings for both strict cookies and shared cookies across subdomains.

  • Company:
  • App:
  • Docs Site:
SettingStrict (not shared)Shared with docs
Base URL