Comments (2)
im seeing the same problem on NextJS 13.2.4
in a route.ts
in my app
folder
using NextResponse.cookies.set()
to set multiple cookies yields a single Set-Cookie
http response header...
const response = NextResponse.redirect(location, 303);
response.cookies.set({
name: ACCESS_TOKEN,
value: result.accessToken,
path: '/',
secure,
expires: result.expiresOn ? result.expiresOn : undefined,
});
response.cookies.set({
name: ACCOUNT_ID,
value: result.account.homeAccountId,
path: '/',
secure,
expires: expiration('years', 1),
});
return response;
set-cookie: access-token=mytokenvalue; Path=/; Expires=Mon, 27 Mar 2023 04:38:03 GMT, account-id=1c12dd32-abcd-4e0a-9d21-5b480b806b06-b2c_1a_passwordless-authentication.abcdedf-1136-40a6-a376-123456789; Path=/; Expires=Tue, 26 Mar 2024 04:44:43 GMT
from the spec:
Origin servers SHOULD NOT fold multiple Set-Cookie header fields into a single header field. The usual mechanism for folding HTTP headers fields (i.e., as defined in [RFC2616]) might change the semantics of the Set-Cookie header field because the %x2C (",") character is used by Set-Cookie in a way that conflicts with such folding.
comma is used in the Expires attribute value
from edge-runtime.
I'm not seeing this issue at Next.js v13.4.10:
import { NextResponse } from 'next/server'
export const config = { runtime: 'edge' }
export default req => {
const response = new NextResponse()
response.cookies
.set('cookie1', 'cookie1')
.set('cookie2', 'cookie2')
return response
}
That produces the following headers:
$ curl -i http://localhost:3000/api
HTTP/1.1 200 OK
set-cookie: cookie1=cookie1; Path=/
set-cookie: cookie2=cookie2; Path=/
date: Mon, 17 Jul 2023 15:49:55 GMT
connection: close
transfer-encoding: chunked
Closing for now; Happy to reopen if you can provide a reproducing of the issue using the latest version 🙂
from edge-runtime.
Related Issues (20)
- Expose cookie serialization functions. HOT 1
- Include a key in process.versions for detecting edge runtime HOT 2
- Support `has` in ResponseCookies
- Set-Cookie headers are merged when using `fetch` HOT 6
- Primitives: event-target-shim causes issues w/ edge-runtime running on top of node HOT 3
- drop node16 support
- Proxying primitive instances return anonymous `toString()` return functions
- Why cannot my `fetch` API work in edge function? HOT 4
- 🙏`fetch` api doesn't work in edge function HOT 4
- Which functions and APIs advance the value returned by `Date.now`? HOT 3
- Polyfill for btoa inconsistent with WebApi / Node HOT 5
- drop node18 support
- Response.redirect() fails to parse some URLs in production which parse successfully in local runtime HOT 2
- `@edge-runtime/node-utils` can't start example server from docs using `primitives` (node v18.18.2) Headers2 is not a constructor HOT 1
- Secure Cookies can't be deleted from Responses
- CompressionStream / DecompressionStream support?
- failing on buffer
- Does Edge Runtime use alternative vm instead of node:vm? HOT 3
- crypto.subtle.importKey does not accept ArrayBuffer (ArrayBuffer.prototype mismatch) HOT 1
- Cannot use @edge-runtime/jest-environment
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from edge-runtime.