Skip to content

Commit

Permalink
Merge branch 'canary' into shu/hroc
Browse files Browse the repository at this point in the history
  • Loading branch information
shuding committed Dec 20, 2022
2 parents b9d47ae + cafb886 commit afbb503
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 @@ -369,12 +369,6 @@ const configSchema = {
sharedPool: {
type: 'boolean',
},
skipMiddlewareUrlNormalize: {
type: 'boolean',
},
skipTrailingSlashRedirect: {
type: 'boolean',
},
sri: {
properties: {
algorithm: {
Expand Down Expand Up @@ -691,6 +685,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 @@ -506,6 +503,12 @@ export interface NextConfig extends Record<string, any> {

// A list of packages that should always be transpiled and bundled in the server
transpilePackages?: string[]

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 afbb503

Please sign in to comment.