solidjs / solid-start

SolidStart, the Solid app framework
https://start.solidjs.com
MIT License
4.95k stars 371 forks source link

[Bug?]: how to prerender *404 page? #1574

Open huseeiin opened 5 days ago

huseeiin commented 5 days ago

Duplicates

Latest version

Current behavior 😯

when i prerender /about it creates a about/index.html file correctly. but when i prerender "/*404" it generates nothing.

Expected behavior 🤔

No response

Steps to reproduce 🕹

import { defineConfig } from "@solidjs/start/config";

export default defineConfig({
  server: {
    preset: "cloudflare-pages",
    prerender: { routes: ["/*404"] },
  },
});

Context 🔦

No response

Your environment 🌎

No response

huseeiin commented 5 days ago

I dont think this is possible with Nitro? I'm not sure this is a SolidStart problem?

well, since solidstart uses nitro, it is a solidstart problem even if it originates from nitro

mdynnl commented 3 days ago

using the code provided with these versions

├── @solidjs/meta@0.29.4
├── @solidjs/router@0.13.6
├── @solidjs/start@1.0.2
├── solid-js@1.8.18
└── vinxi@0.3.12

cloudflare-pages

Screenshot 2024-07-06 at 05 57 59

but you probably don't need it for this preset as workers can already serve a 404 page

cloudflare-pages-static

import { defineConfig } from '@solidjs/start/config';

export default defineConfig({
  server: {
    preset: 'cloudflare-pages-static',
    prerender: {
      // crawlLinks: true, // required for `cloudflare-pages` preset
      autoSubfolderIndex: false,
      routes: ['/404'],
    },
  },
});

This might be what you want which also generates a redirect rule /* /404.html 404 which for some reason is not supported yet But 404.html will be detected and will be used as 404 redirection expcept for /404 which returns 200

Screenshot 2024-07-06 at 06 27 31