Skip to content

Commit

Permalink
Move options to stable (#44195)
Browse files Browse the repository at this point in the history
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)
  • Loading branch information
shuding committed Dec 20, 2022
1 parent 2b3a38e commit cafb886
Show file tree
Hide file tree
Showing 8 changed files with 26 additions and 27 deletions.
3 changes: 1 addition & 2 deletions packages/next/build/index.ts
Expand Up @@ -797,8 +797,7 @@ export default async function build(
header: RSC,
varyHeader: RSC_VARY_HEADER,
},
skipMiddlewareUrlNormalize:
config.experimental.skipMiddlewareUrlNormalize,
skipMiddlewareUrlNormalize: config.skipMiddlewareUrlNormalize,
}
})

Expand Down
9 changes: 4 additions & 5 deletions packages/next/build/webpack-config.ts
Expand Up @@ -302,13 +302,13 @@ export function getDefineEnv({
'process.env.__NEXT_I18N_DOMAINS': JSON.stringify(config.i18n?.domains),
'process.env.__NEXT_ANALYTICS_ID': JSON.stringify(config.analyticsId),
'process.env.__NEXT_ALLOW_MIDDLEWARE_RESPONSE_BODY': JSON.stringify(
config.experimental.allowMiddlewareResponseBody
config.allowMiddlewareResponseBody
),
'process.env.__NEXT_NO_MIDDLEWARE_URL_NORMALIZE': JSON.stringify(
config.experimental.skipMiddlewareUrlNormalize
config.skipMiddlewareUrlNormalize
),
'process.env.__NEXT_MANUAL_TRAILING_SLASH': JSON.stringify(
config.experimental?.skipTrailingSlashRedirect
config.skipTrailingSlashRedirect
),
'process.env.__NEXT_HAS_WEB_VITALS_ATTRIBUTION': JSON.stringify(
config.experimental.webVitalsAttribution &&
Expand Down Expand Up @@ -2062,8 +2062,7 @@ export default async function getBaseWebpackConfig(
dev,
sriEnabled: !dev && !!config.experimental.sri?.algorithm,
hasFontLoaders: !!config.experimental.fontLoaders,
allowMiddlewareResponseBody:
!!config.experimental.allowMiddlewareResponseBody,
allowMiddlewareResponseBody: !!config.allowMiddlewareResponseBody,
}),
isClient &&
new BuildManifestPlugin({
Expand Down
2 changes: 1 addition & 1 deletion packages/next/lib/load-custom-routes.ts
Expand Up @@ -659,7 +659,7 @@ export default async function loadCustomRoutes(
)
}

if (!config.experimental?.skipTrailingSlashRedirect) {
if (!config.skipTrailingSlashRedirect) {
if (config.trailingSlash) {
redirects.unshift(
{
Expand Down
18 changes: 9 additions & 9 deletions packages/next/server/config-schema.ts
Expand Up @@ -7,6 +7,9 @@ const configSchema = {
type: 'object',
additionalProperties: false,
properties: {
allowMiddlewareResponseBody: {
type: 'boolean',
},
amp: {
additionalProperties: false,
properties: {
Expand Down Expand Up @@ -269,9 +272,6 @@ const configSchema = {
appDir: {
type: 'boolean',
},
allowMiddlewareResponseBody: {
type: 'boolean',
},
externalDir: {
type: 'boolean',
},
Expand Down Expand Up @@ -375,12 +375,6 @@ const configSchema = {
sharedPool: {
type: 'boolean',
},
skipMiddlewareUrlNormalize: {
type: 'boolean',
},
skipTrailingSlashRedirect: {
type: 'boolean',
},
sri: {
properties: {
algorithm: {
Expand Down Expand Up @@ -697,6 +691,12 @@ const configSchema = {
serverRuntimeConfig: {
type: 'object',
},
skipMiddlewareUrlNormalize: {
type: 'boolean',
},
skipTrailingSlashRedirect: {
type: 'boolean',
},
staticPageGenerationTimeout: {
type: 'number',
},
Expand Down
9 changes: 6 additions & 3 deletions packages/next/server/config-shared.ts
Expand Up @@ -80,9 +80,6 @@ export interface NextJsWebpackConfig {

export interface ExperimentalConfig {
fetchCache?: boolean
allowMiddlewareResponseBody?: boolean
skipMiddlewareUrlNormalize?: boolean
skipTrailingSlashRedirect?: boolean
optimisticClientCache?: boolean
middlewarePrefetch?: 'strict' | 'flexible'
legacyBrowsers?: boolean
Expand Down Expand Up @@ -507,6 +504,12 @@ export interface NextConfig extends Record<string, any> {

output?: 'standalone'

allowMiddlewareResponseBody?: boolean

skipMiddlewareUrlNormalize?: boolean

skipTrailingSlashRedirect?: boolean

/**
* Enable experimental features. Note that all experimental features are subject to breaking changes in the future.
*/
Expand Down
2 changes: 1 addition & 1 deletion packages/next/server/next-server.ts
Expand Up @@ -1716,7 +1716,7 @@ export default class NextNodeServer extends BaseServer {

let url: string

if (this.nextConfig.experimental.skipMiddlewareUrlNormalize) {
if (this.nextConfig.skipMiddlewareUrlNormalize) {
url = getRequestMeta(params.request, '__NEXT_INIT_URL')!
} else {
// For middleware to "fetch" we must always provide an absolute URL
Expand Down
2 changes: 1 addition & 1 deletion test/e2e/app-dir/app-middleware/next.config.js
@@ -1,6 +1,6 @@
module.exports = {
allowMiddlewareResponseBody: true,
experimental: {
appDir: true,
allowMiddlewareResponseBody: true,
},
}
8 changes: 3 additions & 5 deletions test/e2e/skip-trailing-slash-redirect/app/next.config.js
@@ -1,10 +1,8 @@
/** @type {import('next').NextConfig} */
const nextConfig = {
experimental: {
skipTrailingSlashRedirect: true,
skipMiddlewareUrlNormalize: true,
allowMiddlewareResponseBody: true,
},
allowMiddlewareResponseBody: true,
skipMiddlewareUrlNormalize: true,
skipTrailingSlashRedirect: true,
async redirects() {
return [
{
Expand Down

0 comments on commit cafb886

Please sign in to comment.