英文:
"404: not found" error on SolidJS project deployed to Vercel
问题
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!
英文:
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!
答案1
得分: 1
更改我的vite配置为以下内容:
plugins: [solid({adapter: vercel()})],
英文:
The answer was to change my vite config to plugins to
'''
plugins: [solid({adapter: vercel()})],
'''
答案2
得分: 0
继续@Harry Albert的回答:
你需要运行 `npm i solid-start-vercel` 来安装 SolidJS 适配器 ***Vercel***
然后添加:
```javascript
import vercel from "solid-start-vercel";
到 vite.config.ts 文件中,还要添加:
export default defineConfig({
plugins: [
solid({ adapter: vercel({ edge: true }) })
],
});
我尝试过 solid({ adapter: vercel() })
但出现了错误,因为 vercel()
函数需要一个类型为 SolidStartVercelOptions 的参数,它包含以下键:
{
edge: boolean,
includes: string | string[],
excludes: string | string[],
prerender: PrerenderFunctionConfig
}
如果你安装了 vercel cli,运行以下命令:
vercel env add ENABLE_VC_BUILD
然后将 ENABLE_VC_BUILD 的值设置为 1
希望这提供了足够的信息给需要的人。
参考链接:
SolidJS Github Issue About Vercel
<details>
<summary>英文:</summary>
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][1]
[SolidJS Github Issue About Vercel][2]
[1]: https://github.com/solidjs/solid-start/tree/cbafb3108b79533f6492719af74842df1c7fe26e/packages/start-vercel
[2]: https://github.com/solidjs/solid-start/issues/591
</details>
通过集体智慧和协作来改善编程学习和解决问题的方式。致力于成为全球开发者共同参与的知识库,让每个人都能够通过互相帮助和分享经验来进步。
评论