Skip to content

Commit 431b1f9

Browse files
authored
fix: include base static redirect for i18n sites too (#36)
* fix: include base static redirect for i18n sites too * fix: update snapshot
1 parent 97cd996 commit 431b1f9

File tree

2 files changed

+10
-5
lines changed

2 files changed

+10
-5
lines changed

src/helpers/config.js

+4-4
Original file line numberDiff line numberDiff line change
@@ -76,12 +76,12 @@ exports.generateRedirects = async ({ netlifyConfig, basePath, i18n }) => {
7676
redirects.push(...getNetlifyRoutes(route), ...getNetlifyRoutes(dataRoute))
7777
})
7878

79-
// Needed only for /_next/static
80-
const i18nSplat = i18n ? '/:locale' : ''
81-
79+
if (i18n) {
80+
netlifyConfig.redirects.push({ from: `${basePath}/:locale/_next/static/*`, to: `/static/:splat`, status: 200 })
81+
}
8282
// This is only used in prod, so dev uses `next dev` directly
8383
netlifyConfig.redirects.push(
84-
{ from: `${basePath}${i18nSplat}/_next/static/*`, to: `${i18nSplat}/static/:splat`, status: 200 },
84+
{ from: `${basePath}/_next/static/*`, to: `/static/:splat`, status: 200 },
8585
{
8686
from: `${basePath}/*`,
8787
to: HANDLER_FUNCTION_PATH,

test/__snapshots__/index.js.snap

+6-1
Original file line numberDiff line numberDiff line change
@@ -74,7 +74,12 @@ Array [
7474
Object {
7575
"from": "/:locale/_next/static/*",
7676
"status": 200,
77-
"to": "/:locale/static/:splat",
77+
"to": "/static/:splat",
78+
},
79+
Object {
80+
"from": "/_next/static/*",
81+
"status": 200,
82+
"to": "/static/:splat",
7883
},
7984
Object {
8085
"conditions": Object {

0 commit comments

Comments
 (0)