“404:未找到” 错误在部署到 Vercel 的 SolidJS 项目上。

huangapple go评论62阅读模式
英文:

"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!
“404:未找到” 错误在部署到 Vercel 的 SolidJS 项目上。

答案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 Vercel Adapter Github

SolidJS Github Issue About Vercel


<details>
<summary>英文:</summary>

Adding on to @Harry Alberts answer:

You&#39;ll need to `npm i solid-start-vercel` to install SolidJS ***Adapter for Vercel***

Then add:
 

    import vercel from &quot;solid-start-vercel&quot;;

 
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>



huangapple
  • 本文由 发表于 2023年5月10日 22:44:51
  • 转载请务必保留本文链接:https://go.coder-hub.com/76219797.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定