analog icon indicating copy to clipboard operation
analog copied to clipboard

[Bug] nitro.compressPublicAssets = true breaks SSR on / route

Open renatoaraujoc opened this issue 5 months ago • 0 comments

Please provide the environment you discovered this bug in.

There's no need for an environement.

Which area/package is the issue in?

vite-plugin-nitro

Description

When opt-in for compressPublicAssets, the following analog() config fails to render / route as SSR and just spits out the non-rendered version of it, example:

analog({
    ssr: true,
    prerender: {
        routes: ['/']
    },
    nitro: {
        routeRules: {
            '/': {
                prerender: false
            }
        },
        compressPublicAssets: true, // or { brotli: true, gzip: true }
    }
})

The above will create 1/2 files (depending on the config):

./dist/app/analog/public/index.html.gz ./dist/app/analog/public/index.html.br

Screenshot 2024-09-22 at 06 49 08

The files above will be reconized by nitro server as static assets and will not go thru the SSR rendering, as seen here:

Screenshot 2024-09-22 at 06 51 44

Screenshot 2024-09-22 at 06 52 26

Turning off compressPublicAssets solves the issue and / is renderable again, but we lose the compressed stuff.

Solution: strip out index.html from being .gz'd and br'd in the public folder so nitro server doesn't include it on the assets array.

Please provide the exception or error you saw

No response

Other information

No response

I would be willing to submit a PR to fix this issue

  • [ ] Yes
  • [X] No

renatoaraujoc avatar Sep 22 '24 09:09 renatoaraujoc