2

I recently created a personal website using SolidJS, with server side rendering and typescript enabled. I attempted to deploy this site to Vercel, with the only change from the base Vercel settings being that I changed the Output Directory to 'dist'. However, after deploying the site I am getting a 404 error. You can find the uploaded site (and the error) here, and the github repo for my solidjs project here. I have also attached a screenshot of my Vercel Build & Development Settings. Does anyone have any advice on how to fix this issue? Thank you! Vercel Build & Development Settings

3 Answers 3

1

The answer was to change my vite config to plugins to ''' plugins: [solid({adapter: vercel()})], '''

Sign up to request clarification or add additional context in comments.

1 Comment

add this line: server: {preset: "vercel"}
1

Adding on to @Harry Alberts answer:

You'll need to npm i solid-start-vercel to install SolidJS Adapter for Vercel

Then add:

import vercel from "solid-start-vercel";

to the vite.config.ts file along with this:

export default defineConfig({
    plugins: [
        solid({ adapter: vercel({ edge: true }) })
    ],
});

I tried this solid({ adapter: vercel() }) but got an error since the vercel() function expects an argument of type SolidStartVercelOptions which has these as keys:

{
  edge: boolean,
  includes: string | string[],
  excludes: string | string[],
  prerender: PrerenderFunctionConfig
}

And if you have the vercel cli installed, run this:

vercel env add ENABLE_VC_BUILD

and set the the value of ENABLE_VC_BUILD to 1

Hope this is enough information for those needing it.

Reference:

SolidJs Vercel Adapter Github

SolidJS Github Issue About Vercel

1 Comment

vite.config.ts and adapter no longer are needed. see my solution below
1

As of 2024 June 27, SolidStart 1.0.2 + SolidJs 1.8.17 comes with app.config.ts. So delete vercel.json, and vite.config.js.

In your app.config.ts, add this line: server: {preset: "vercel"}

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

export default defineConfig({
        server: {preset: "vercel"}
    //plugins: [solid({ adapter: vercel() })]
});

In Vercal project settings:

  • Under Build & Development Settings: leave all settings blank.
  • Usually your Solid project should be in your repo root. So leave Root Directory setting empty.
  • Under Node.js Version: setting here should match the NodeJs version you use during development, and the setting in your package.json:
  "engines": {
    "node": ">=20.12.2"
  }

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.