Unverified Commit cafb886e authored by Shu Ding's avatar Shu Ding Committed by GitHub

Move options to stable (#44195)

This PR moves `allowMiddlewareResponseBody`, `skipMiddlewareUrlNormalize` and `skipTrailingSlashRedirect` to stable.

## Bug

- [ ] Related issues linked using `fixes #number`
- [ ] Integration tests added
- [ ] Errors have a helpful link attached, see [`contributing.md`](https://github.com/vercel/next.js/blob/canary/contributing.md)

## Feature

- [ ] Implements an existing feature request or RFC. Make sure the feature request has been accepted for implementation before opening a PR.
- [ ] Related issues linked using `fixes #number`
- [ ] [e2e](https://github.com/vercel/next.js/blob/canary/contributing/core/testing.md#writing-tests-for-nextjs) tests added
- [ ] Documentation added
- [ ] Telemetry added. In case of a feature if it's used or not.
- [ ] Errors have a helpful link attached, see [`contributing.md`](https://github.com/vercel/next.js/blob/canary/contributing.md)

## Documentation / Examples

- [ ] Make sure the linting passes by running `pnpm build && pnpm lint`
- [ ] The "examples guidelines" are followed from [our contributing doc](https://github.com/vercel/next.js/blob/canary/contributing/examples/adding-examples.md)
parent 2b3a38ee
...@@ -797,8 +797,7 @@ export default async function build( ...@@ -797,8 +797,7 @@ export default async function build(
header: RSC, header: RSC,
varyHeader: RSC_VARY_HEADER, varyHeader: RSC_VARY_HEADER,
}, },
skipMiddlewareUrlNormalize: skipMiddlewareUrlNormalize: config.skipMiddlewareUrlNormalize,
config.experimental.skipMiddlewareUrlNormalize,
} }
}) })
......
...@@ -302,13 +302,13 @@ export function getDefineEnv({ ...@@ -302,13 +302,13 @@ export function getDefineEnv({
'process.env.__NEXT_I18N_DOMAINS': JSON.stringify(config.i18n?.domains), 'process.env.__NEXT_I18N_DOMAINS': JSON.stringify(config.i18n?.domains),
'process.env.__NEXT_ANALYTICS_ID': JSON.stringify(config.analyticsId), 'process.env.__NEXT_ANALYTICS_ID': JSON.stringify(config.analyticsId),
'process.env.__NEXT_ALLOW_MIDDLEWARE_RESPONSE_BODY': JSON.stringify( 'process.env.__NEXT_ALLOW_MIDDLEWARE_RESPONSE_BODY': JSON.stringify(
config.experimental.allowMiddlewareResponseBody config.allowMiddlewareResponseBody
), ),
'process.env.__NEXT_NO_MIDDLEWARE_URL_NORMALIZE': JSON.stringify( 'process.env.__NEXT_NO_MIDDLEWARE_URL_NORMALIZE': JSON.stringify(
config.experimental.skipMiddlewareUrlNormalize config.skipMiddlewareUrlNormalize
), ),
'process.env.__NEXT_MANUAL_TRAILING_SLASH': JSON.stringify( 'process.env.__NEXT_MANUAL_TRAILING_SLASH': JSON.stringify(
config.experimental?.skipTrailingSlashRedirect config.skipTrailingSlashRedirect
), ),
'process.env.__NEXT_HAS_WEB_VITALS_ATTRIBUTION': JSON.stringify( 'process.env.__NEXT_HAS_WEB_VITALS_ATTRIBUTION': JSON.stringify(
config.experimental.webVitalsAttribution && config.experimental.webVitalsAttribution &&
...@@ -2062,8 +2062,7 @@ export default async function getBaseWebpackConfig( ...@@ -2062,8 +2062,7 @@ export default async function getBaseWebpackConfig(
dev, dev,
sriEnabled: !dev && !!config.experimental.sri?.algorithm, sriEnabled: !dev && !!config.experimental.sri?.algorithm,
hasFontLoaders: !!config.experimental.fontLoaders, hasFontLoaders: !!config.experimental.fontLoaders,
allowMiddlewareResponseBody: allowMiddlewareResponseBody: !!config.allowMiddlewareResponseBody,
!!config.experimental.allowMiddlewareResponseBody,
}), }),
isClient && isClient &&
new BuildManifestPlugin({ new BuildManifestPlugin({
......
...@@ -659,7 +659,7 @@ export default async function loadCustomRoutes( ...@@ -659,7 +659,7 @@ export default async function loadCustomRoutes(
) )
} }
if (!config.experimental?.skipTrailingSlashRedirect) { if (!config.skipTrailingSlashRedirect) {
if (config.trailingSlash) { if (config.trailingSlash) {
redirects.unshift( redirects.unshift(
{ {
......
...@@ -7,6 +7,9 @@ const configSchema = { ...@@ -7,6 +7,9 @@ const configSchema = {
type: 'object', type: 'object',
additionalProperties: false, additionalProperties: false,
properties: { properties: {
allowMiddlewareResponseBody: {
type: 'boolean',
},
amp: { amp: {
additionalProperties: false, additionalProperties: false,
properties: { properties: {
...@@ -269,9 +272,6 @@ const configSchema = { ...@@ -269,9 +272,6 @@ const configSchema = {
appDir: { appDir: {
type: 'boolean', type: 'boolean',
}, },
allowMiddlewareResponseBody: {
type: 'boolean',
},
externalDir: { externalDir: {
type: 'boolean', type: 'boolean',
}, },
...@@ -375,12 +375,6 @@ const configSchema = { ...@@ -375,12 +375,6 @@ const configSchema = {
sharedPool: { sharedPool: {
type: 'boolean', type: 'boolean',
}, },
skipMiddlewareUrlNormalize: {
type: 'boolean',
},
skipTrailingSlashRedirect: {
type: 'boolean',
},
sri: { sri: {
properties: { properties: {
algorithm: { algorithm: {
...@@ -697,6 +691,12 @@ const configSchema = { ...@@ -697,6 +691,12 @@ const configSchema = {
serverRuntimeConfig: { serverRuntimeConfig: {
type: 'object', type: 'object',
}, },
skipMiddlewareUrlNormalize: {
type: 'boolean',
},
skipTrailingSlashRedirect: {
type: 'boolean',
},
staticPageGenerationTimeout: { staticPageGenerationTimeout: {
type: 'number', type: 'number',
}, },
......
...@@ -80,9 +80,6 @@ export interface NextJsWebpackConfig { ...@@ -80,9 +80,6 @@ export interface NextJsWebpackConfig {
export interface ExperimentalConfig { export interface ExperimentalConfig {
fetchCache?: boolean fetchCache?: boolean
allowMiddlewareResponseBody?: boolean
skipMiddlewareUrlNormalize?: boolean
skipTrailingSlashRedirect?: boolean
optimisticClientCache?: boolean optimisticClientCache?: boolean
middlewarePrefetch?: 'strict' | 'flexible' middlewarePrefetch?: 'strict' | 'flexible'
legacyBrowsers?: boolean legacyBrowsers?: boolean
...@@ -507,6 +504,12 @@ export interface NextConfig extends Record<string, any> { ...@@ -507,6 +504,12 @@ export interface NextConfig extends Record<string, any> {
output?: 'standalone' output?: 'standalone'
allowMiddlewareResponseBody?: boolean
skipMiddlewareUrlNormalize?: boolean
skipTrailingSlashRedirect?: boolean
/** /**
* Enable experimental features. Note that all experimental features are subject to breaking changes in the future. * Enable experimental features. Note that all experimental features are subject to breaking changes in the future.
*/ */
......
...@@ -1716,7 +1716,7 @@ export default class NextNodeServer extends BaseServer { ...@@ -1716,7 +1716,7 @@ export default class NextNodeServer extends BaseServer {
let url: string let url: string
if (this.nextConfig.experimental.skipMiddlewareUrlNormalize) { if (this.nextConfig.skipMiddlewareUrlNormalize) {
url = getRequestMeta(params.request, '__NEXT_INIT_URL')! url = getRequestMeta(params.request, '__NEXT_INIT_URL')!
} else { } else {
// For middleware to "fetch" we must always provide an absolute URL // For middleware to "fetch" we must always provide an absolute URL
......
module.exports = { module.exports = {
allowMiddlewareResponseBody: true,
experimental: { experimental: {
appDir: true, appDir: true,
allowMiddlewareResponseBody: true,
}, },
} }
/** @type {import('next').NextConfig} */ /** @type {import('next').NextConfig} */
const nextConfig = { const nextConfig = {
experimental: { allowMiddlewareResponseBody: true,
skipTrailingSlashRedirect: true, skipMiddlewareUrlNormalize: true,
skipMiddlewareUrlNormalize: true, skipTrailingSlashRedirect: true,
allowMiddlewareResponseBody: true,
},
async redirects() { async redirects() {
return [ return [
{ {
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment