Skip to content

Child routes 404 when application is served statically using web server #5501

Closed Answered by AllenAttuned
AllenAttuned asked this question in Q&A
Discussion options

You must be logged in to vote

Here are some notes on a working solution. To serve the SPA as a static website, (1) you'll need to configure Modern.js to produce a build directory that looks like the one below, and (2) a proper web server configuration.

.
|____index.html
|____nestedRoutes.json
|____route.json
|____static/
| |____css/
| |____js/
| |____font/
|____routes-manifest.json

This is the minimum modern.config.ts needed to achieve this:

export default defineConfig({
    output: {
        cleanDistPath: true,
        distPath: {
            html: '',
        },
    },
    html: {
        disableHtmlFolder: true,
    },
    runtime: {
        router: true,
    },
    source: {
        mainEntryName: 'index',
    },

Replies: 2 comments 1 reply

Comment options

You must be logged in to vote
1 reply
@AllenAttuned
Comment options

Comment options

You must be logged in to vote
0 replies
Answer selected by AllenAttuned
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants