From ec0ae5315f9b414b5b83e39bc0697217984f3cda Mon Sep 17 00:00:00 2001 From: Hebilicious Date: Thu, 20 Jul 2023 13:37:45 +0700 Subject: [PATCH] fix: append set cookie header --- packages/authjs-nuxt/package.json | 10 ++++---- packages/authjs-nuxt/src/runtime/utils.ts | 5 ++-- pnpm-lock.yaml | 28 +++++------------------ 3 files changed, 12 insertions(+), 31 deletions(-) diff --git a/packages/authjs-nuxt/package.json b/packages/authjs-nuxt/package.json index cd8758c..3a42bcb 100644 --- a/packages/authjs-nuxt/package.json +++ b/packages/authjs-nuxt/package.json @@ -47,16 +47,14 @@ "cookie": "^0.5.0", "cookie-es": "^1.0.0", "defu": "^6.1.2", + "h3": "^1.7.1", "immer": "^10.0.2", "jose": "^4.14.4", - "set-cookie-parser": "^2.6.0", - "unctx": "^2.3.1" + "unctx": "^2.3.1", + "vue": "^3.3.4" }, "devDependencies": { - "@nuxt/module-builder": "^0.4.0", - "@types/set-cookie-parser": "^2.4.3", - "h3": "^1.7.1", - "vue": "^3.3.4" + "@nuxt/module-builder": "^0.4.0" }, "bundledDependencies": [ "@panva/hkdf", diff --git a/packages/authjs-nuxt/src/runtime/utils.ts b/packages/authjs-nuxt/src/runtime/utils.ts index c7598eb..943c703 100644 --- a/packages/authjs-nuxt/src/runtime/utils.ts +++ b/packages/authjs-nuxt/src/runtime/utils.ts @@ -1,8 +1,7 @@ import type { AuthConfig } from "@auth/core" import { parse } from "cookie-es" import type { H3Event, RequestHeaders } from "h3" -import { getMethod, getRequestHeaders, getRequestURL, readRawBody, sendRedirect } from "h3" -import { splitCookiesString } from "set-cookie-parser" +import { getMethod, getRequestHeaders, getRequestURL, readRawBody, sendRedirect, splitCookiesString } from "h3" import type { RuntimeConfig } from "@nuxt/schema" export const configKey = "authJs" @@ -81,7 +80,7 @@ export async function getRequestFromEvent(event: H3Event) { */ export async function respondWithResponse(event: H3Event, response: Response) { for (const [key, value] of response.headers) { - if (key === "set-cookie") event.node.res.setHeader(key, splitCookiesString(value)) + if (key === "set-cookie") event.node.res.appendHeader(key, splitCookiesString(value)) else event.node.res.setHeader(key, value) } diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml index 92ec6da..23c6058 100644 --- a/pnpm-lock.yaml +++ b/pnpm-lock.yaml @@ -89,6 +89,9 @@ importers: defu: specifier: ^6.1.2 version: 6.1.2 + h3: + specifier: ^1.7.1 + version: 1.7.1 immer: specifier: ^10.0.2 version: 10.0.2 @@ -98,25 +101,16 @@ importers: nuxt: specifier: ^3.6.1 version: 3.6.1(@types/node@20.3.3)(eslint@8.44.0)(rollup@3.21.5)(typescript@5.1.6) - set-cookie-parser: - specifier: ^2.6.0 - version: 2.6.0 unctx: specifier: ^2.3.1 version: 2.3.1 + vue: + specifier: ^3.3.4 + version: 3.3.4 devDependencies: '@nuxt/module-builder': specifier: ^0.4.0 version: 0.4.0(@nuxt/kit@3.6.1)(nuxi@3.6.1) - '@types/set-cookie-parser': - specifier: ^2.4.3 - version: 2.4.3 - h3: - specifier: ^1.7.1 - version: 1.7.1 - vue: - specifier: ^3.3.4 - version: 3.3.4 playgrounds/credentials: dependencies: @@ -2375,12 +2369,6 @@ packages: resolution: {integrity: sha512-21cFJr9z3g5dW8B0CVI9g2O9beqaThGQ6ZFBqHfwhzLDKUxaqTIy3vnfah/UPkfOiF2pLq+tGz+W8RyCskuslw==} dev: true - /@types/set-cookie-parser@2.4.3: - resolution: {integrity: sha512-7QhnH7bi+6KAhBB+Auejz1uV9DHiopZqu7LfR/5gZZTkejJV5nYeZZpgfFoE0N8aDsXuiYpfKyfyMatCwQhyTQ==} - dependencies: - '@types/node': 20.3.3 - dev: true - /@types/unist@2.0.6: resolution: {integrity: sha512-PBjIUxZHOuj0R15/xuwJYjFi+KZdNFrehocChv4g5hu6aFroHue8m0lBP0POdK2nKzbw0cgV1mws8+V/JAcEkQ==} dev: true @@ -8598,10 +8586,6 @@ packages: /set-blocking@2.0.0: resolution: {integrity: sha512-KiKBS8AnWGEyLzofFfmvKwpdPzqiy16LvQfK3yv/fVH7Bj13/wl3JSR1J+rfgRE9q7xUJK4qvgS8raSOeLUehw==} - /set-cookie-parser@2.6.0: - resolution: {integrity: sha512-RVnVQxTXuerk653XfuliOxBP81Sf0+qfQE73LIYKcyMYHG94AuH0kgrQpRDuTZnSmjpysHmzxJXKNfa6PjFhyQ==} - dev: false - /setprototypeof@1.2.0: resolution: {integrity: sha512-E5LDX7Wrp85Kil5bhZv46j8jOeboKq5JMmYM3gVGdGH8xFpPWXUMsNrlODCrkoxMEeNi/XZIwuRvY4XNwYMJpw==}