forked from Rosetta/landing
Фикс 404 при обновелнии страницы
This commit is contained in:
@@ -1,5 +1,5 @@
|
||||
import { copyFile, mkdir } from 'node:fs/promises';
|
||||
import { resolve } from 'node:path';
|
||||
import { dirname, resolve } from 'node:path';
|
||||
|
||||
const root = process.cwd();
|
||||
const outputDirectory = resolve(root, 'dist');
|
||||
@@ -20,13 +20,17 @@ await copyFile(
|
||||
resolve(serverDirectory, 'index.js'),
|
||||
);
|
||||
|
||||
// Emit an extensionless HTML match for every client-side route. This keeps
|
||||
// browser refreshes working even when the asset layer handles navigations
|
||||
// before the Worker gets a chance to return the SPA fallback.
|
||||
// Emit both clean-URL and directory-index shells for every client-side route.
|
||||
// The directory copy also supports basic Nginx static configurations that do
|
||||
// not rewrite missing paths to the root application shell.
|
||||
await Promise.all(
|
||||
browserRoutes.map(async (route) => {
|
||||
const routeFile = resolve(outputDirectory, `${route}.html`);
|
||||
await mkdir(resolve(routeFile, '..'), { recursive: true });
|
||||
const routeDirectory = resolve(outputDirectory, route);
|
||||
|
||||
await mkdir(dirname(routeFile), { recursive: true });
|
||||
await mkdir(routeDirectory, { recursive: true });
|
||||
await copyFile(appShell, routeFile);
|
||||
await copyFile(appShell, resolve(routeDirectory, 'index.html'));
|
||||
}),
|
||||
);
|
||||
|
||||
Reference in New Issue
Block a user