Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Unable to set domain via extraCookieOptions. Test suite failing with error message - Cookie has domain set to the public suffix "localhost" which is a special use domain #170

Closed
sachinm opened this issue Aug 24, 2022 · 2 comments

Comments

@sachinm
Copy link

sachinm commented Aug 24, 2022

Unit test failing with the error message:
Cookie has domain set to the public suffix "localhost"
which is a special use domain. To allow this, configure your CookieJar with {allowSpecialUseDomain:true, rejectPublicSuffixes: false}

Below is the component definition:
<CookieConsent
style={{
background: '#e2e3ef',
color: '#6b7286'
}}
location='bottom'
buttonText='Accept'
extraCookieOptions={{
domain:'.testing-cookieconsent.com'
}}>We use cookies to improve your website experience.

Full stack-trace of error msg in my react/typescript app:
Cookie has domain set to the public suffix "localhost"
which is a special use domain. To allow this, configure your CookieJar with {allowSpecialUseDomain:true, rejectPublicSuffixes: false}.
at Object.getPublicSuffix (node_modules/tough-cookie/lib/pubsuffix-psl.js:62:11)
at permuteDomain (node_modules/tough-cookie/lib/permuteDomain.js:38:28)
at MemoryCookieStore.findCookies (node_modules/tough-cookie/lib/memstore.js:99:21)
at MemoryCookieStore.findCookies (node_modules/tough-cookie/node_modules/universalify/index.js:5:67)
at CookieJar.getCookies (node_modules/tough-cookie/lib/cookie.js:1407:11)
at CookieJar.getCookies (node_modules/tough-cookie/node_modules/universalify/index.js:5:67)
at CookieJar.getCookieString (node_modules/tough-cookie/lib/cookie.js:1452:21)
at CookieJar.getCookieString (node_modules/tough-cookie/node_modules/universalify/index.js:5:67)
at CookieJar.getCookieStringSync (node_modules/tough-cookie/lib/cookie.js:1723:17)
at DocumentImpl.get cookie [as cookie] (node_modules/jsdom/lib/jsdom/living/nodes/Document-impl.js:860:28)
Anyone else run into this issue and suggest possible solution? thanks in advance

@dnekkalapu
Copy link

there is an active discussion going on here for various work arounds salesforce/tough-cookie#246

@Mastermindzh
Copy link
Owner

As pointed out by @dnekkalapu, this is not an issue with the library itself but rather with tough-cookie and a breaking change in their 4.1 version.

Good luck though!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants