Skip to content

Middleware fails on Cloudflare Pages/Workers #260

Description

@joeygrable94

Description

I built a 1-to-1 replica of the basic example in this code base and attempted to deploy to cloudflare pages and cloudflare workers. I've narrowed it down to the clerk-solidjs middleware...

When I include the clerk-solidjs middleware.ts file in the app.config.ts and try to build for cloudflare, I get a "500 Request Error - internal server error"

However, when I do not include the middleware then it builds and deploys successfully, however, when I navigate to the /protected route which uses a server function to load the session it throws a "Error | Uncaught Client Exception" page error.

Code example

Issues

This builds successfully, but cannot access /protected route

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

export default defineConfig({
  // middleware: "./src/middleware.ts",
  server: {
    preset: "cloudflare-pages",
    rollupConfig: {
      external: ["node:async_hooks"]
    }
  },
  vite: {
    plugins: [],
  },
});

This builds, but throws 500 internal server error

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

export default defineConfig({
  middleware: "./src/middleware.ts",
  server: {
    preset: "cloudflare-pages",
    rollupConfig: {
      external: ["node:async_hooks"]
    }
  },
  vite: {
    plugins: [],
  },
});

Additional context

No response

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Fields

    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions