Skip to content

Commit

Permalink
Merge branch 'canary' into fix-52935
Browse files Browse the repository at this point in the history
  • Loading branch information
ijjk authored Apr 4, 2024
2 parents 132a960 + c502308 commit 9256f1f
Show file tree
Hide file tree
Showing 4 changed files with 33 additions and 4 deletions.
1 change: 1 addition & 0 deletions packages/next/src/server/lib/server-ipc/utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ export const ipcForbiddenHeaders = [
export const actionsForbiddenHeaders = [
...ipcForbiddenHeaders,
'content-length',
'set-cookie',
]

export const filterReqHeaders = (
Expand Down
Original file line number Diff line number Diff line change
@@ -1,8 +1,12 @@
import { redirect } from 'next/navigation'
import { cookies } from 'next/headers'

async function action() {
'use server'

cookies().set(
'custom-server-action-test-cookie',
'custom-server-action-test-cookie-val'
)
redirect('/another')
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,10 @@ async function main() {
try {
const parsedUrl = parse(req.url, true)
const { pathname } = parsedUrl

res.setHeader(
'set-cookie',
'custom-server-test-cookie=custom-server-test-cookie-val'
)
if (pathname.startsWith('/base')) {
await handle(req, res, parsedUrl)
} else {
Expand Down
25 changes: 23 additions & 2 deletions test/e2e/app-dir/app-basepath-custom-server/index.test.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { join } from 'path'
import { createNextDescribe } from 'e2e-utils'
import { retry } from 'next-test-utils'
import { check, retry } from 'next-test-utils'
import { join } from 'path'

createNextDescribe(
'custom-app-server-action-redirect',
Expand Down Expand Up @@ -35,5 +35,26 @@ createNextDescribe(
// Count should still be 2 as the browser should not have reloaded the page.
expect(await getCount()).toBe('Count: 2')
})

it('redirects with proper cookies set from both redirect response and post respose', async () => {
const browser = await next.browser('/base')

await browser.elementById('submit-server-action-redirect').click()

expect(await browser.waitForElementByCss('#another').text()).toBe(
'Another Page'
)
expect(await browser.url()).toBe(
`http://localhost:${next.appPort}/base/another`
)
await check(
() => browser.eval('document.cookie'),
/custom-server-test-cookie/
)
await check(
() => browser.eval('document.cookie'),
/custom-server-action-test-cookie/
)
})
}
)

0 comments on commit 9256f1f

Please sign in to comment.