Compare commits

..

4 Commits

Author SHA1 Message Date
JJ Kasper
fd5d3b2921 Publish Stable
- @vercel/next@2.6.30
2020-10-20 13:11:20 -05:00
JJ Kasper
d22bdeb8d0 Publish Canary
- @vercel/next@2.6.30-canary.0
2020-10-20 12:59:12 -05:00
JJ Kasper
c120fd82f9 [next] Ensure root-most index GSP page is located correctly (#5309) 2020-10-20 19:58:18 +02:00
JJ Kasper
2474a80ff1 Correct i18n trailing slash redirect priority (#5306) 2020-10-20 11:01:31 -05:00
4 changed files with 24 additions and 7 deletions

View File

@@ -1,6 +1,6 @@
{
"name": "@vercel/next",
"version": "2.6.29",
"version": "2.6.30",
"license": "MIT",
"main": "./dist/index",
"homepage": "https://vercel.com/docs/runtimes#official-runtimes/next-js",

View File

@@ -10,7 +10,7 @@ import {
PrepareCacheOptions,
Prerender,
} from '@vercel/build-utils';
import { Handler, Route } from '@vercel/routing-utils';
import { Handler, Route, Source } from '@vercel/routing-utils';
import {
convertHeaders,
convertRedirects,
@@ -1651,6 +1651,7 @@ export const build = async ({
// if there isn't a srcRoute then it's a non-dynamic SSG page and
if (nonDynamicSsg || isFallback) {
routeFileNoExt = addLocaleOrDefault(
// root index files are located without folder/index.html
routeFileNoExt,
routesManifest,
locale
@@ -1968,22 +1969,27 @@ export const build = async ({
...headers,
// redirects
...redirects.map(redir => {
...redirects.map(_redir => {
if (i18n) {
const redir = _redir as Source;
// detect the trailing slash redirect and make sure it's
// kept above the wildcard mapping to prevent erroneous redirects
// since non-continue routes come after continue the $wildcard
// route will come before the redirect otherwise and if the
// redirect is triggered it breaks locale mapping
const location =
redir.headers && (redir.headers.location || redir.headers.Location);
if (
redir.status === 308 &&
(redir.dest === '/$1' || redir.dest === '/$1/')
(location === '/$1' || location === '/$1/')
) {
// we set continue true
(redir as any).continue = true;
redir.continue = true;
}
}
return redir;
return _redir;
}),
...(i18n

View File

@@ -1110,7 +1110,9 @@ export function addLocaleOrDefault(
if (!routesManifest?.i18n) return pathname;
if (!locale) locale = routesManifest.i18n.defaultLocale;
return locale ? `/${locale}${pathname}` : pathname;
return locale
? `/${locale}${pathname === '/index' ? '' : pathname}`
: pathname;
}
export {

View File

@@ -44,3 +44,12 @@ export default function Page(props) {
</>
);
}
export const getStaticProps = ({ locale, locales }) => {
return {
props: {
locale,
locales,
},
};
};