File tree Expand file tree Collapse file tree 1 file changed +13
-5
lines changed
packages/brick-container/serve Expand file tree Collapse file tree 1 file changed +13
-5
lines changed Original file line number Diff line number Diff line change @@ -103,6 +103,7 @@ export default function getProxy(env, getRawIndexHtml) {
103103 return responseBuffer ;
104104 }
105105
106+ // Add or clear secure related cookie flags
106107 const secureCookieFlags = [
107108 "SameSite=None" ,
108109 "Secure" ,
@@ -115,12 +116,19 @@ export default function getProxy(env, getRawIndexHtml) {
115116 req . path === "/next/api/auth/login/v2" &&
116117 Array . isArray ( setCookies )
117118 ) {
119+ // - If the server is https, but the local is http, clear the secure cookie flags;
120+ // - Otherwise, if the local is localhost and cookieSameSiteNone is enabled (default),
121+ // add the secure cookie flags;
122+ // - Otherwise, if the local is https, do nothing;
123+ // - Otherwise, clear the secure cookie flags;
118124 const strategy =
119- env . cookieSameSiteNone && env . host === "localhost"
120- ? "add"
121- : env . https
122- ? null
123- : "clear" ;
125+ env . server . startsWith ( "https:" ) && ! env . https
126+ ? "clear"
127+ : env . cookieSameSiteNone && env . host === "localhost"
128+ ? "add"
129+ : env . https
130+ ? null
131+ : "clear" ;
124132 if ( strategy ) {
125133 // Note: it seems that now Chrome (v107) requires `SameSite=None` even for localhost.
126134 // However, `Secure` can use used with non-http for localhost.
You can’t perform that action at this time.
0 commit comments