solidjs / solid-start

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

[Bug?]: 404 page doesn't work in cloudflare pages #1527

Closed huseeiin closed 2 weeks ago

huseeiin commented 3 weeks ago

Duplicates

Latest version

Current behavior 😯

going to a page that doesn't exist in cloudflare pages shows a blank page with a Uncaught (in promise) Error: Context is not available error in the browser console

Expected behavior 🤔

for [...404].tsx to render correctly

Steps to reproduce 🕹

Steps:

1.create a solid start project 2.wrangler pages deploy dist 3.go to /page-that-doesnt-exist 4.empty page

Context 🔦

No response

Your environment 🌎

No response

Brendonovich commented 3 weeks ago

Add unenv as a dependency, add the nodejs_compat compatability flag to your pages project, and put this in your config:

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

export default defineConfig({
  server: {
    preset: "cloudflare-pages",
    unenv: cloudflare,
  },
});

I think this will be done as part of the cloudflare preset at some point: https://github.com/unjs/nitro/issues/1943

huseeiin commented 2 weeks ago

nodejs_compat

worked! thanks!

huseeiin commented 2 weeks ago

Add unenv as a dependency, add the nodejs_compat compatability flag to your pages project, and put this in your config:

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

export default defineConfig({
  server: {
    preset: "cloudflare-pages",
    unenv: cloudflare,
  },
});

I think this will be done as part of the cloudflare preset at some point: unjs/nitro#1943

but, without the 404 status code?