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

Trailing slash basepath #14781

Merged
merged 15 commits into from
Jul 13, 2020
Merged
Prev Previous commit
Next Next commit
revert method
  • Loading branch information
Janpot committed Jul 1, 2020
commit 52f67c4635ac905579bd90535db7c29f23a1a6d0
6 changes: 3 additions & 3 deletions packages/next/lib/load-custom-routes.ts
Original file line number Diff line number Diff line change
Expand Up @@ -350,19 +350,19 @@ export default async function loadCustomRoutes(
? [
{
source: '/:path*/:file.:ext/',
destination: '/:path*/:file.:ext',
destination: config.basePath + '/:path*/:file.:ext',
permanent: true,
},
{
source: '/:path*/:notfile([^/.]+)',
destination: '/:path*/:notfile/',
destination: config.basePath + '/:path*/:notfile/',
permanent: true,
},
]
: [
{
source: '/:path+/',
destination: '/:path+',
destination: config.basePath + '/:path+',
permanent: true,
},
])
Expand Down
9 changes: 1 addition & 8 deletions packages/next/next-server/server/next-server.ts
Original file line number Diff line number Diff line change
Expand Up @@ -65,10 +65,6 @@ import { PagesManifest } from '../../build/webpack/plugins/pages-manifest-plugin
import { removePathTrailingSlash } from '../../client/normalize-trailing-slash'
import getRouteFromAssetPath from '../lib/router/utils/get-route-from-asset-path'

function addBasePath(path: string, basePath: string = ''): string {
return basePath ? (path === '/' ? basePath : basePath + path) : path
}

const getCustomRouteMatcher = pathMatch(true)

type NextConfig = any
Expand Down Expand Up @@ -513,10 +509,7 @@ export default class Server {
params,
parsedUrl.query
)
const updatedDestination = addBasePath(
formatUrl(parsedDestination),
this.nextConfig.basePath
)
const updatedDestination = formatUrl(parsedDestination)

res.setHeader('Location', updatedDestination)
res.statusCode = getRedirectStatus(redirectRoute as Redirect)
Expand Down