Skip to content

Commit a9b22fc

Browse files
Merge branch 'main' into tRaCe
2 parents 3399455 + f051e22 commit a9b22fc

File tree

2 files changed

+5
-2
lines changed

2 files changed

+5
-2
lines changed

packages/runtime/src/helpers/functions.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -269,7 +269,7 @@ const traceNextServer = async (publish: string): Promise<string[]> => {
269269

270270
export const traceNPMPackage = async (packageName: string, publish: string) => {
271271
try {
272-
return await glob(join(dirname(require.resolve(packageName, { paths: [publish] })), '**', '*'), {
272+
return await glob(join(dirname(require.resolve(packageName, { paths: [__dirname, publish] })), '**', '*'), {
273273
absolute: true,
274274
})
275275
} catch (error) {

packages/runtime/src/templates/edge-shared/utils.ts

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -58,6 +58,8 @@ export const addMiddlewareHeaders = async (
5858
}
5959

6060
interface ResponseCookies {
61+
// This is non-standard that Next.js adds.
62+
// See github.com/vercel/next.js/blob/de08f8b3d31ef45131dad97a7d0e95fa01001167/packages/next/src/compiled/@edge-runtime/cookies/index.js#L158
6163
readonly _headers: Headers
6264
}
6365

@@ -191,7 +193,8 @@ export const buildResponse = async ({
191193
}
192194

193195
// NextResponse doesn't set cookies onto the originResponse, so we need to copy them over
194-
if (response.cookies._headers.has('set-cookie')) {
196+
// In some cases, it's possible there are no headers set. See https://github.com/netlify/pod-ecosystem-frameworks/issues/475
197+
if (response.cookies._headers?.has('set-cookie')) {
195198
response.originResponse.headers.set('set-cookie', response.cookies._headers.get('set-cookie')!)
196199
}
197200

0 commit comments

Comments
 (0)