astro-tractstack 2.2.3 → 2.2.4
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/package.json
CHANGED
|
@@ -1,28 +1,17 @@
|
|
|
1
1
|
import type { APIRoute } from '@/types/astro';
|
|
2
2
|
|
|
3
|
-
export const POST: APIRoute = async ({ cookies }) => {
|
|
3
|
+
export const POST: APIRoute = async ({ cookies, url }) => {
|
|
4
4
|
try {
|
|
5
|
-
const
|
|
6
|
-
|
|
7
|
-
let rootDomain: string | undefined;
|
|
5
|
+
const isLocalhost =
|
|
6
|
+
url.hostname === 'localhost' || url.hostname === '127.0.0.1';
|
|
8
7
|
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
} catch (e) {
|
|
16
|
-
console.warn('Logout: Failed to parse backend URL for cookie domain', e);
|
|
17
|
-
}
|
|
18
|
-
|
|
19
|
-
// Determine the options ONCE to prevent overwriting
|
|
20
|
-
const cookieOptions: any = { path: '/' };
|
|
21
|
-
if (rootDomain) {
|
|
22
|
-
cookieOptions.domain = rootDomain;
|
|
23
|
-
}
|
|
8
|
+
const cookieOptions: any = {
|
|
9
|
+
path: '/',
|
|
10
|
+
secure: !isLocalhost,
|
|
11
|
+
httpOnly: true,
|
|
12
|
+
sameSite: 'lax',
|
|
13
|
+
};
|
|
24
14
|
|
|
25
|
-
// Execute deletion with the single, correct configuration
|
|
26
15
|
cookies.delete('admin_auth', cookieOptions);
|
|
27
16
|
cookies.delete('editor_auth', cookieOptions);
|
|
28
17
|
|