Fix cookie domain issue for persisting setting (#73)
Co-authored-by: AceDataCloud <office@acedata.cloud>
This commit is contained in:
1 parent
19e1d0196f
commit
b6d26c1ad2
4 files changed
+32
-8
No files matched your search
@@ -0,0 +1,7 @@
|
||||
{
|
||||
"type": "patch",
|
||||
"comment": "fix the cookie domain",
|
||||
"packageName": "@acedatacloud/nexior",
|
||||
"email": "office@acedata.cloud",
|
||||
"dependentChangeType": "patch"
|
||||
}
|
||||
@@ -44,6 +44,7 @@
|
||||
"highlight.js": "^11.7.0",
|
||||
"mac-scrollbar": "^0.13.5",
|
||||
"markdown-it": "^13.0.1",
|
||||
"psl": "^1.9.0",
|
||||
"qrcode": "^1.5.1",
|
||||
"qs": "^6.11.2",
|
||||
"query-string": "^8.1.0",
|
||||
@@ -65,6 +66,7 @@
|
||||
"@types/lodash": "^4.14.172",
|
||||
"@types/markdown-it": "^12.2.3",
|
||||
"@types/node": "^16.7.4",
|
||||
"@types/psl": "^1.1.3",
|
||||
"@types/qs": "^6.9.9",
|
||||
"@types/uuid": "^8.3.4",
|
||||
"@typescript-eslint/eslint-plugin": "^5.17.0",
|
||||
|
||||
@@ -4,15 +4,20 @@ import { getLocale } from '@/i18n';
|
||||
import store from '@/store';
|
||||
import { log } from './log';
|
||||
import { IToken } from '@/models';
|
||||
import psl from 'psl';
|
||||
|
||||
export const getDomain = () => {
|
||||
const host = window.location.hostname;
|
||||
// process test env and prod env, for example:
|
||||
// hub.acedata.cloud -> .acedata.cloud
|
||||
// hub.test.acedata.cloud -> .acedata.cloud
|
||||
const domain = host.replace(/^\S+?\.(test\.|local\.)?/, '.');
|
||||
console.log('cookies domain', domain);
|
||||
return domain;
|
||||
export const getDomain = (host: string = window.location.hostname) => {
|
||||
if (host === 'localhost') {
|
||||
return host;
|
||||
}
|
||||
const parsed = psl.parse(host);
|
||||
if (parsed.error) {
|
||||
return host;
|
||||
}
|
||||
if (parsed.domain === host) {
|
||||
return host;
|
||||
}
|
||||
return '.' + parsed.domain;
|
||||
};
|
||||
|
||||
export const initializeCookies = async () => {
|
||||
|
||||
@@ -634,6 +634,11 @@
|
||||
resolved "https://registry.npmjs.org/@types/node/-/node-16.11.22.tgz"
|
||||
integrity sha512-DYNtJWauMQ9RNpesl4aVothr97/tIJM8HbyOXJ0AYT1Z2bEjLHyfjOBPAQQVMLf8h3kSShYfNk8Wnto8B2zHUA==
|
||||
|
||||
"@types/psl@^1.1.3":
|
||||
version "1.1.3"
|
||||
resolved "https://registry.yarnpkg.com/@types/psl/-/psl-1.1.3.tgz#c1e9febd70e7df248ac9911cdd145454643aa28f"
|
||||
integrity sha512-Iu174JHfLd7i/XkXY6VDrqSlPvTDQOtQI7wNAXKKOAADJ9TduRLkNdMgjGiMxSttUIZnomv81JAbAbC0DhggxA==
|
||||
|
||||
"@types/qs@^6.9.9":
|
||||
version "6.9.9"
|
||||
resolved "https://registry.npmjs.org/@types/qs/-/qs-6.9.9.tgz"
|
||||
@@ -3718,6 +3723,11 @@ proxy-from-env@^1.1.0:
|
||||
resolved "https://registry.npmjs.org/proxy-from-env/-/proxy-from-env-1.1.0.tgz"
|
||||
integrity sha512-D+zkORCbA9f1tdWRK0RaCR3GPv50cMxcrz4X8k5LTSUD1Dkw47mKJEZQNunItRTkWwgtaUSo1RVFRIG9ZXiFYg==
|
||||
|
||||
psl@^1.9.0:
|
||||
version "1.9.0"
|
||||
resolved "https://registry.yarnpkg.com/psl/-/psl-1.9.0.tgz#d0df2a137f00794565fcaf3b2c00cd09f8d5a5a7"
|
||||
integrity sha512-E/ZsdU4HLs/68gYzgGTkMicWTLPdAftJLfJFlLUAAKZGkStNU72sZjT66SnMDVOfOWY/YAoiD7Jxa9iHvngcag==
|
||||
|
||||
punycode@^2.1.0:
|
||||
version "2.3.1"
|
||||
resolved "https://registry.npmjs.org/punycode/-/punycode-2.3.1.tgz"
|
||||
|
||||
Reference in new issue
Block a user