Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Move options to stable #44195

Merged
merged 3 commits into from Dec 20, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
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,
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Lets handle these similar to #44194 (comment)

}),
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