Skip to content

Commit

Permalink
fix(electron): cookie redirecting issue (#8347)
Browse files Browse the repository at this point in the history
  • Loading branch information
pengx17 committed Sep 23, 2024
1 parent f9e0c1e commit 503e020
Showing 1 changed file with 3 additions and 2 deletions.
5 changes: 3 additions & 2 deletions packages/frontend/apps/electron/src/main/protocol.ts
Original file line number Diff line number Diff line change
Expand Up @@ -110,7 +110,8 @@ export function registerProtocol() {
const protocol = url.protocol;
const origin = url.origin;

const sameOrigin = origin === CLOUD_BASE_URL || protocol === 'file:';
const sameSite =
url.host === new URL(CLOUD_BASE_URL).host || protocol === 'file:';

// offline whitelist
// 1. do not block non-api request for http://localhost || file:// (local dev assets)
Expand Down Expand Up @@ -142,7 +143,7 @@ export function registerProtocol() {

// session cookies are set to file:// on production
// if sending request to the cloud, attach the session cookie (to affine cloud server)
if (isNetworkResource(pathname) && sameOrigin) {
if (isNetworkResource(pathname) && sameSite) {
const cookie = getCookies();
if (cookie) {
const cookieString = cookie.map(c => `${c.name}=${c.value}`).join('; ');
Expand Down

0 comments on commit 503e020

Please sign in to comment.