Skip to content

Commit 66abb19

Browse files
committed
fix: serve static files from basePath
1 parent ec95bba commit 66abb19

File tree

3 files changed

+5
-4
lines changed

3 files changed

+5
-4
lines changed

packages/runtime/src/helpers/files.ts

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -434,10 +434,12 @@ export const movePublicFiles = async ({
434434
appDir,
435435
outdir,
436436
publish,
437+
basePath,
437438
}: {
438439
appDir: string
439440
outdir?: string
440441
publish: string
442+
basePath: string
441443
}): Promise<void> => {
442444
// `outdir` is a config property added when using Next.js with Nx. It's typically
443445
// a relative path outside of the appDir, e.g. '../../dist/apps/<app-name>', and
@@ -447,6 +449,6 @@ export const movePublicFiles = async ({
447449
// directory from the original app directory.
448450
const publicDir = outdir ? join(appDir, outdir, 'public') : join(appDir, 'public')
449451
if (existsSync(publicDir)) {
450-
await copy(publicDir, `${publish}/`)
452+
await copy(publicDir, `${publish}${basePath}/`)
451453
}
452454
}

packages/runtime/src/index.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -155,7 +155,7 @@ const plugin: NetlifyPlugin = {
155155
await generateFunctions(constants, appDir, apiRoutes)
156156
await generatePagesResolver(constants)
157157

158-
await movePublicFiles({ appDir, outdir, publish })
158+
await movePublicFiles({ appDir, outdir, publish, basePath })
159159

160160
await patchNextFiles(appDir)
161161

test/e2e/modified-tests/i18n-ignore-rewrite-source-locale/rewrites-with-basepath.test.ts

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -47,8 +47,7 @@ describe('i18n-ignore-rewrite-source-locale with basepath', () => {
4747
})
4848
})
4949
afterAll(() => next.destroy())
50-
// NTL Fail
51-
test.skip.each(locales)('get public file by skipping locale in rewrite, locale: %s', async (locale) => {
50+
test.each(locales)('get public file by skipping locale in rewrite, locale: %s', async (locale) => {
5251
const res = await renderViaHTTP(next.url, `/basepath${locale}/rewrite-files/file.txt`)
5352
expect(res).toContain('hello from file.txt')
5453
})

0 commit comments

Comments
 (0)