Skip to content
Permalink

Comparing changes

Choose two branches to see what’s changed or to start a new pull request. If you need to, you can also or learn more about diff comparisons.

Open a pull request

Create a new pull request by comparing changes across two branches. If you need to, you can also . Learn more about diff comparisons here.
base repository: vercel/next.js
Failed to load repositories. Confirm that selected base ref is valid, then try again.
Loading
base: v15.2.2
Choose a base ref
...
head repository: vercel/next.js
Failed to load repositories. Confirm that selected head ref is valid, then try again.
Loading
compare: v15.2.3
Choose a head ref
  • 9 commits
  • 57 files changed
  • 4 contributors

Commits on Mar 17, 2025

  1. [metadata] re-insert icons to head for streamed metadata (#76915)

    ### What
    
    Re-insert the metadata icons under body tag into head tag to ensure they
    can be proper displayed.
    
    ### Why
    
    * For chromium based browsers (Chrome, Edge, etc.) and Safari, icons
    need to stay under `<head>` to be picked up by the browser. Firefox
    doesn't have this requirement.
    * Firefox will always render svg > icon > png, so it doesn't matter to
    it.
    
    
    Made a test in https://icons-order-test.vercel.app/, you can play with
    the test cases here. These links can see the comparsion of the approach
    in the this PR.
    
    During deployment it's very hard to verify Safari as it's pretty broken.
    But deploymet works well.
    After we re-insert the icon from body into head, they can be properly
    displayed across all the browsers.
    
    Note: We insert the script during streaming rather than using a jsx
    element right after metadata to avoid the hydration errors
    
    Closes #76810
    Closes NDX-951
    huozhi committed Mar 17, 2025
    Copy the full SHA
    88deb12 View commit details
  2. [ts-hint] fix vscode type hint plugin enabling (#77099)

    ### What
    
    Fix the enabling of ts hint plugin in vscode. This is a regression
    introduced in #76300, where we use the plugin config `{ "name": "next"
    }` to directly check if it has a `enabled` property, and determine if we
    should enable the plugin. This PR fixed the way of reading plugin config
    and keep it enabled by default.
    
    Fixes 76980
    huozhi committed Mar 17, 2025
    Copy the full SHA
    1e1ff40 View commit details
  3. [metadata] remove the default segement check for metadata rendering (#…

    …77119)
    
    ### What
    
    Remove the default segment checks for metadata rendering. When the
    `default.js` is rendered, it should still have the metadata. It was a
    condition added due to possible of duplicated metadata, but it's
    resolved by other conditions such as only rendering in child slot, and
    hoisting metadata into rsc head for navigation.
    huozhi committed Mar 17, 2025
    Copy the full SHA
    4698ad6 View commit details
  4. Update middleware request header (#77201)

    This just adds an additional header to our internal filtering list for
    middleware.
    ijjk authored and huozhi committed Mar 17, 2025
    Copy the full SHA
    52a078d View commit details
  5. Ensure deploymentId is used for CSS preloads (#77210)

    This just ensures we use the deployment ID if configured for preload CSS
    links.
    
    x-ref: [slack
    thread](https://vercel.slack.com/archives/C03S8ED1DKM/p1742146672858189)
    ijjk authored and huozhi committed Mar 17, 2025
    Copy the full SHA
    8151cb6 View commit details
  6. Add dev warning for cross-origin and stabilize allowedDevOrigins (#77044

    )
    
    Adding a warning when we block cross-origin requests in dev so users are
    aware this is why easier and know how to allow the origin through as
    custom setups can use different origins and it be valid.
    
    x-ref:
    #76880 (comment)
    
    ---------
    
    Co-authored-by: Jiachi Liu <inbox@huozhi.im>
    Co-authored-by: Zack Tanner <1939140+ztanner@users.noreply.github.com>
    3 people committed Mar 17, 2025
    Copy the full SHA
    5e59da1 View commit details
  7. unify allowed origin detection handling (#77053)

    This unifies the CSRF origin detection to mirror what we do for server
    action origins, which supports things like wildcard matches (below the
    domain level)
    
    Fixes #76999
    ztanner authored and huozhi committed Mar 17, 2025
    Copy the full SHA
    adf5462 View commit details
  8. Update default allowed origins list (#77212)

    Per feedback in #76880 this
    ensures we ocnsider `*.localhost` as allowed by default for the dev
    origins list.
    ijjk authored and huozhi committed Mar 17, 2025
    Copy the full SHA
    2fcae1d View commit details
  9. v15.2.3

    vercel-release-bot committed Mar 17, 2025
    Copy the full SHA
    535e26d View commit details
Showing with 383 additions and 76 deletions.
  1. +18 −0 docs/01-app/04-api-reference/05-config/01-next-config-js/allowedDevOrigins.mdx
  2. +7 −0 docs/02-pages/03-api-reference/04-config/01-next-config-js/allowedDevOrigins.mdx
  3. +1 −1 lerna.json
  4. +1 −1 packages/create-next-app/package.json
  5. +2 −2 packages/eslint-config-next/package.json
  6. +1 −1 packages/eslint-plugin-next/package.json
  7. +1 −1 packages/font/package.json
  8. +1 −1 packages/next-bundle-analyzer/package.json
  9. +1 −1 packages/next-codemod/package.json
  10. +1 −1 packages/next-env/package.json
  11. +1 −1 packages/next-mdx/package.json
  12. +1 −1 packages/next-plugin-rspack/package.json
  13. +1 −1 packages/next-plugin-storybook/package.json
  14. +1 −1 packages/next-polyfill-module/package.json
  15. +1 −1 packages/next-polyfill-nomodule/package.json
  16. +1 −1 packages/next-swc/package.json
  17. +7 −7 packages/next/package.json
  18. 0 .../next/src/client/components/metadata/{server-inserted-metadata.ts → server-inserted-metadata.tsx}
  19. +0 −1 packages/next/src/lib/metadata/generate/icons.tsx
  20. +8 −7 packages/next/src/server/app-render/app-render.tsx
  21. +6 −14 packages/next/src/server/app-render/create-component-tree.tsx
  22. +15 −2 packages/next/src/server/app-render/metadata-insertion/create-server-inserted-metadata.tsx
  23. +1 −0 packages/next/src/server/config-schema.ts
  24. +3 −0 packages/next/src/server/config-shared.ts
  25. +8 −1 packages/next/src/server/lib/router-server.ts
  26. +9 −3 packages/next/src/server/lib/router-utils/block-cross-site.ts
  27. +11 −0 packages/next/src/server/lib/server-ipc/utils.ts
  28. +8 −8 packages/next/src/server/typescript/index.ts
  29. +4 −0 packages/next/src/server/web/sandbox/context.ts
  30. +5 −1 packages/next/src/shared/lib/lazy-dynamic/preload-chunks.tsx
  31. +1 −1 packages/react-refresh-utils/package.json
  32. +2 −2 packages/third-parties/package.json
  33. +8 −8 pnpm-lock.yaml
  34. +25 −0 test/e2e/app-dir/metadata-icons/app/custom-icon/page.tsx
  35. +25 −0 test/e2e/app-dir/metadata-icons/app/custom-icon/sub/page.tsx
  36. +63 −0 test/e2e/app-dir/metadata-icons/metadata-icons.test.ts
  37. BIN test/e2e/app-dir/metadata-icons/public/heart.png
  38. BIN test/e2e/app-dir/metadata-icons/public/star.png
  39. +1 −1 test/e2e/app-dir/metadata-streaming/app/dynamic-api/page.tsx
  40. +3 −0 test/e2e/app-dir/metadata-streaming/app/parallel-routes-default/@bar/default.tsx
  41. +8 −0 test/e2e/app-dir/metadata-streaming/app/parallel-routes-default/@bar/layout.tsx
  42. +3 −0 test/e2e/app-dir/metadata-streaming/app/parallel-routes-default/@bar/page.tsx
  43. +3 −0 test/e2e/app-dir/metadata-streaming/app/parallel-routes-default/@bar/test-page/page.tsx
  44. +3 −0 test/e2e/app-dir/metadata-streaming/app/parallel-routes-default/@foo/default.tsx
  45. +8 −0 test/e2e/app-dir/metadata-streaming/app/parallel-routes-default/@foo/layout.tsx
  46. +3 −0 test/e2e/app-dir/metadata-streaming/app/parallel-routes-default/@foo/no-bar/page.tsx
  47. +3 −0 test/e2e/app-dir/metadata-streaming/app/parallel-routes-default/@foo/page.tsx
  48. +3 −0 test/e2e/app-dir/metadata-streaming/app/parallel-routes-default/@foo/test-page/page.tsx
  49. +3 −0 test/e2e/app-dir/metadata-streaming/app/parallel-routes-default/default.tsx
  50. +22 −0 test/e2e/app-dir/metadata-streaming/app/parallel-routes-default/layout.tsx
  51. +13 −0 test/e2e/app-dir/metadata-streaming/app/parallel-routes-default/no-bar/page.tsx
  52. +13 −0 test/e2e/app-dir/metadata-streaming/app/parallel-routes-default/test-page/page.tsx
  53. +10 −3 test/e2e/app-dir/metadata-streaming/app/parallel-routes/no-bar/page.tsx
  54. +3 −1 test/e2e/app-dir/metadata-streaming/app/parallel-routes/page.tsx
  55. +1 −1 test/e2e/app-dir/metadata-streaming/app/parallel-routes/test-page/page.tsx
  56. +18 −0 test/e2e/app-dir/metadata-streaming/metadata-streaming.test.ts
  57. +13 −0 test/e2e/middleware-general/test/index.test.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
---
title: allowedDevOrigins
description: Use `allowedDevOrigins` to configure additional origins that can request the dev server.
---

{/* The content of this doc is shared between the app and pages router. You can use the `<PagesOnly>Content</PagesOnly>` component to add content that is specific to the Pages Router. Any shared content should not be wrapped in a component. */}

To configure a Next.js application to allow requests from origins other than the hostname the server was initialized with (`localhost` by default) you can use the `allowedDevOrigins` config option.

`allowedDevOrigins` allows you to set additional origins that can be used in development mode. For example, to use `local-origin.dev` instead of only `localhost`, open `next.config.js` and add the `allowedDevOrigins` config:

```js filename="next.config.js"
module.exports = {
allowedDevOrigins: ['local-origin.dev', '*.local-origin.dev'],
}
```

Cross-origin requests are blocked by default to prevent unauthorized requesting of internal assets/endpoints which are available in development mode. This behavior is similar to other dev servers like `webpack-dev-middleware` to ensure the same protection.
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
---
title: allowedDevOrigins
description: Use `allowedDevOrigins` to configure additional origins that can request the dev server.
source: app/api-reference/config/next-config-js/allowedDevOrigins
---

{/* DO NOT EDIT. The content of this doc is generated from the source above. To edit the content of this page, navigate to the source page in your editor. You can use the `<PagesOnly>Content</PagesOnly>` component to add content that is specific to the Pages Router. Any shared content should not be wrapped in a component. */}
2 changes: 1 addition & 1 deletion lerna.json
Original file line number Diff line number Diff line change
@@ -16,5 +16,5 @@
"registry": "https://registry.npmjs.org/"
}
},
"version": "15.2.2"
"version": "15.2.3"
}
2 changes: 1 addition & 1 deletion packages/create-next-app/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "create-next-app",
"version": "15.2.2",
"version": "15.2.3",
"keywords": [
"react",
"next",
4 changes: 2 additions & 2 deletions packages/eslint-config-next/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "eslint-config-next",
"version": "15.2.2",
"version": "15.2.3",
"description": "ESLint configuration used by Next.js.",
"main": "index.js",
"license": "MIT",
@@ -10,7 +10,7 @@
},
"homepage": "https://nextjs.org/docs/app/api-reference/config/eslint",
"dependencies": {
"@next/eslint-plugin-next": "15.2.2",
"@next/eslint-plugin-next": "15.2.3",
"@rushstack/eslint-patch": "^1.10.3",
"@typescript-eslint/eslint-plugin": "^5.4.2 || ^6.0.0 || ^7.0.0 || ^8.0.0",
"@typescript-eslint/parser": "^5.4.2 || ^6.0.0 || ^7.0.0 || ^8.0.0",
2 changes: 1 addition & 1 deletion packages/eslint-plugin-next/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@next/eslint-plugin-next",
"version": "15.2.2",
"version": "15.2.3",
"description": "ESLint plugin for Next.js.",
"main": "dist/index.js",
"license": "MIT",
2 changes: 1 addition & 1 deletion packages/font/package.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "@next/font",
"private": true,
"version": "15.2.2",
"version": "15.2.3",
"repository": {
"url": "vercel/next.js",
"directory": "packages/font"
2 changes: 1 addition & 1 deletion packages/next-bundle-analyzer/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@next/bundle-analyzer",
"version": "15.2.2",
"version": "15.2.3",
"main": "index.js",
"types": "index.d.ts",
"license": "MIT",
2 changes: 1 addition & 1 deletion packages/next-codemod/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@next/codemod",
"version": "15.2.2",
"version": "15.2.3",
"license": "MIT",
"repository": {
"type": "git",
2 changes: 1 addition & 1 deletion packages/next-env/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@next/env",
"version": "15.2.2",
"version": "15.2.3",
"keywords": [
"react",
"next",
2 changes: 1 addition & 1 deletion packages/next-mdx/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@next/mdx",
"version": "15.2.2",
"version": "15.2.3",
"main": "index.js",
"license": "MIT",
"repository": {
2 changes: 1 addition & 1 deletion packages/next-plugin-rspack/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@next/plugin-rspack",
"version": "15.2.2",
"version": "15.2.3",
"repository": {
"url": "vercel/next.js",
"directory": "packages/next-plugin-rspack"
2 changes: 1 addition & 1 deletion packages/next-plugin-storybook/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@next/plugin-storybook",
"version": "15.2.2",
"version": "15.2.3",
"repository": {
"url": "vercel/next.js",
"directory": "packages/next-plugin-storybook"
2 changes: 1 addition & 1 deletion packages/next-polyfill-module/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@next/polyfill-module",
"version": "15.2.2",
"version": "15.2.3",
"description": "A standard library polyfill for ES Modules supporting browsers (Edge 16+, Firefox 60+, Chrome 61+, Safari 10.1+)",
"main": "dist/polyfill-module.js",
"license": "MIT",
2 changes: 1 addition & 1 deletion packages/next-polyfill-nomodule/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@next/polyfill-nomodule",
"version": "15.2.2",
"version": "15.2.3",
"description": "A polyfill for non-dead, nomodule browsers.",
"main": "dist/polyfill-nomodule.js",
"license": "MIT",
2 changes: 1 addition & 1 deletion packages/next-swc/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@next/swc",
"version": "15.2.2",
"version": "15.2.3",
"private": true,
"scripts": {
"clean": "node ../../scripts/rm.mjs native",
14 changes: 7 additions & 7 deletions packages/next/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "next",
"version": "15.2.2",
"version": "15.2.3",
"description": "The React Framework",
"main": "./dist/server/next.js",
"license": "MIT",
@@ -100,7 +100,7 @@
]
},
"dependencies": {
"@next/env": "15.2.2",
"@next/env": "15.2.3",
"@swc/counter": "0.1.3",
"@swc/helpers": "0.5.15",
"busboy": "1.6.0",
@@ -164,11 +164,11 @@
"@jest/types": "29.5.0",
"@mswjs/interceptors": "0.23.0",
"@napi-rs/triples": "1.2.0",
"@next/font": "15.2.2",
"@next/polyfill-module": "15.2.2",
"@next/polyfill-nomodule": "15.2.2",
"@next/react-refresh-utils": "15.2.2",
"@next/swc": "15.2.2",
"@next/font": "15.2.3",
"@next/polyfill-module": "15.2.3",
"@next/polyfill-nomodule": "15.2.3",
"@next/react-refresh-utils": "15.2.3",
"@next/swc": "15.2.3",
"@opentelemetry/api": "1.6.0",
"@playwright/test": "1.41.2",
"@storybook/addon-a11y": "8.6.0",
1 change: 0 additions & 1 deletion packages/next/src/lib/metadata/generate/icons.tsx
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
import type { ResolvedMetadata } from '../types/metadata-interface'
import type { Icon, IconDescriptor } from '../types/metadata-types'

import React from 'react'
import { MetaFilter } from './meta'

function IconDescriptorLink({ icon }: { icon: IconDescriptor }) {
15 changes: 8 additions & 7 deletions packages/next/src/server/app-render/app-render.tsx
Original file line number Diff line number Diff line change
@@ -317,7 +317,7 @@ function createNotFoundLoaderTree(loaderTree: LoaderTree): LoaderTree {
}

function createDivergedMetadataComponents(
Metadata: React.ComponentType<{}>,
Metadata: React.ComponentType,
serveStreamingMetadata: boolean
): {
StaticMetadata: React.ComponentType<{}>
@@ -326,8 +326,9 @@ function createDivergedMetadataComponents(
function EmptyMetadata() {
return null
}
const StreamingMetadata: React.ComponentType<{}> | null =
serveStreamingMetadata ? Metadata : null
const StreamingMetadata: React.ComponentType | null = serveStreamingMetadata
? Metadata
: null

const StaticMetadata: React.ComponentType<{}> = serveStreamingMetadata
? EmptyMetadata
@@ -1711,7 +1712,7 @@ async function renderToStream(
const { ServerInsertedHTMLProvider, renderServerInsertedHTML } =
createServerInsertedHTML()
const { ServerInsertedMetadataProvider, getServerInsertedMetadata } =
createServerInsertedMetadata()
createServerInsertedMetadata(ctx.nonce)

const tracingMetadata = getTracedMetadata(
getTracer().getTracePropagationData(),
@@ -2299,9 +2300,9 @@ async function spawnDynamicValidationInDev(
}
}

const { ServerInsertedHTMLProvider } = createServerInsertedHTML()
const { ServerInsertedMetadataProvider } = createServerInsertedMetadata()
const nonce = '1'
const { ServerInsertedHTMLProvider } = createServerInsertedHTML()
const { ServerInsertedMetadataProvider } = createServerInsertedMetadata(nonce)

if (initialServerStream) {
const [warmupStream, renderStream] = initialServerStream.tee()
@@ -2584,7 +2585,7 @@ async function prerenderToStream(
const { ServerInsertedHTMLProvider, renderServerInsertedHTML } =
createServerInsertedHTML()
const { ServerInsertedMetadataProvider, getServerInsertedMetadata } =
createServerInsertedMetadata()
createServerInsertedMetadata(ctx.nonce)

const tracingMetadata = getTracedMetadata(
getTracer().getTracePropagationData(),
20 changes: 6 additions & 14 deletions packages/next/src/server/app-render/create-component-tree.tsx
Original file line number Diff line number Diff line change
@@ -21,7 +21,6 @@ import type { LoadingModuleData } from '../../shared/lib/app-router-context.shar
import type { Params } from '../request/params'
import { workUnitAsyncStorage } from './work-unit-async-storage.external'
import { OUTLET_BOUNDARY_NAME } from '../../lib/metadata/metadata-constants'
import { DEFAULT_SEGMENT_KEY } from '../../shared/lib/segment'
import type { UseCachePageComponentProps } from '../use-cache/use-cache-wrapper'

/**
@@ -40,7 +39,7 @@ export function createComponentTree(props: {
missingSlots?: Set<string>
preloadCallbacks: PreloadCallbacks
authInterrupts: boolean
StreamingMetadata: React.ComponentType<{}> | null
StreamingMetadata: React.ComponentType | null
StreamingMetadataOutlet: React.ComponentType
}): Promise<CacheNodeSeedData> {
return getTracer().trace(
@@ -92,7 +91,7 @@ async function createComponentTreeInternal({
missingSlots?: Set<string>
preloadCallbacks: PreloadCallbacks
authInterrupts: boolean
StreamingMetadata: React.ComponentType<{}> | null
StreamingMetadata: React.ComponentType | null
StreamingMetadataOutlet: React.ComponentType | null
}): Promise<CacheNodeSeedData> {
const {
@@ -394,19 +393,12 @@ async function createComponentTreeInternal({

// Resolve the segment param
const actualSegment = segmentParam ? segmentParam.treeSegment : segment

// Only render metadata on the actual SSR'd segment not the `default` segment,
// as it's used as a placeholder for navigation.
const isNotDefaultSegment = actualSegment !== DEFAULT_SEGMENT_KEY

const metadata =
isNotDefaultSegment && StreamingMetadata ? <StreamingMetadata /> : undefined
const metadata = StreamingMetadata ? <StreamingMetadata /> : undefined

// Use the same condition to render metadataOutlet as metadata
const metadataOutlet =
isNotDefaultSegment && StreamingMetadataOutlet ? (
<StreamingMetadataOutlet />
) : undefined
const metadataOutlet = StreamingMetadataOutlet ? (
<StreamingMetadataOutlet />
) : undefined

const notFoundElement = NotFound ? (
<>
Original file line number Diff line number Diff line change
@@ -6,7 +6,15 @@ import {
} from '../../../shared/lib/server-inserted-metadata.shared-runtime'
import { renderToString } from '../render-to-string'

export function createServerInsertedMetadata() {
/**
* For chromium based browsers (Chrome, Edge, etc.) and Safari,
* icons need to stay under <head> to be picked up by the browser.
*
*/
const REINSERT_ICON_SCRIPT = `\
document.querySelectorAll('body link[rel="icon"], body link[rel="apple-touch-icon"]').forEach(el => document.head.appendChild(el))`

export function createServerInsertedMetadata(nonce: string | undefined) {
let metadataResolver: MetadataResolver | null = null
let metadataToFlush: React.ReactNode = null
const setMetadataResolver = (resolver: MetadataResolver): void => {
@@ -34,7 +42,12 @@ export function createServerInsertedMetadata() {
metadataToFlush = metadataResolver()
const html = await renderToString({
renderToReadableStream,
element: <>{metadataToFlush}</>,
element: (
<>
{metadataToFlush}
<script nonce={nonce}>{REINSERT_ICON_SCRIPT}</script>
</>
),
})

return html
1 change: 1 addition & 0 deletions packages/next/src/server/config-schema.ts
Original file line number Diff line number Diff line change
@@ -128,6 +128,7 @@ const zTurboRuleConfigItemOrShortcut: zod.ZodType<TurboRuleConfigItemOrShortcut>

export const configSchema: zod.ZodType<NextConfig> = z.lazy(() =>
z.strictObject({
allowedDevOrigins: z.array(z.string()).optional(),
amp: z
.object({
canonicalBase: z.string().optional(),
3 changes: 3 additions & 0 deletions packages/next/src/server/config-shared.ts
Original file line number Diff line number Diff line change
@@ -673,6 +673,8 @@ export type ExportPathMap = {
* Read more: [Next.js Docs: `next.config.js`](https://nextjs.org/docs/app/api-reference/config/next-config-js)
*/
export interface NextConfig extends Record<string, any> {
allowedDevOrigins?: string[]

exportPathMap?: (
defaultMap: ExportPathMap,
ctx: {
@@ -1134,6 +1136,7 @@ export const defaultConfig: NextConfig = {
output: !!process.env.NEXT_PRIVATE_STANDALONE ? 'standalone' : undefined,
modularizeImports: undefined,
outputFileTracingRoot: process.env.NEXT_PRIVATE_OUTPUT_TRACE_ROOT || '',
allowedDevOrigins: [],
experimental: {
allowedDevOrigins: [],
nodeMiddleware: false,
9 changes: 8 additions & 1 deletion packages/next/src/server/lib/router-server.ts
Original file line number Diff line number Diff line change
@@ -166,9 +166,16 @@ export async function initialize(opts: {
renderServer.instance =
require('./render-server') as typeof import('./render-server')

const randomBytes = new Uint8Array(8)
crypto.getRandomValues(randomBytes)
const middlewareSubrequestId = Buffer.from(randomBytes).toString('hex')
;(globalThis as any)[Symbol.for('@next/middleware-subrequest-id')] =
middlewareSubrequestId

const allowedOrigins = [
'*.localhost',
'localhost',
...(config.experimental.allowedDevOrigins || []),
...(config.allowedDevOrigins || []),
]
if (opts.hostname) {
allowedOrigins.push(opts.hostname)
Loading