Skip to content

Commit

Permalink
fix(permission): check and request permission should ignore url port
Browse files Browse the repository at this point in the history
The same cookie is shared by different ports of the same domain name. If a port is added when request permission, the urls of different ports of the same domain name cannot access the current cookie. For example, localhost:8080 requires the cookie of localhost
  • Loading branch information
njzydark committed Nov 21, 2023
1 parent 16446db commit b0df166
Showing 1 changed file with 12 additions and 0 deletions.
12 changes: 12 additions & 0 deletions interface/lib/permissionHandler.js
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,12 @@ export class PermissionHandler {
const testPermission = {
origins: [url],
};
try {
const { protocol, hostname } = new URL(url);
testPermission.origins = [`${protocol}//${hostname}/*`];
} catch (err) {
console.error(err);
}

// If we don't have access to the permission API, assume we have
// access. Safari devtools can't access the API.
Expand All @@ -70,6 +76,12 @@ export class PermissionHandler {
const permission = {
origins: [url],
};
try {
const { protocol, hostname } = new URL(url);
permission.origins = [`${protocol}//${hostname}/*`];
} catch (err) {
console.error(err);
}
return this.browserDetector.getApi().permissions.request(permission);
}
}

0 comments on commit b0df166

Please sign in to comment.