1
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 3 years have passed since last update.

SvelteKit+Prismaで作成したアプリをVercelにデプロイするとエンドポイントが404になる件への対応

Last updated at Posted at 2022-01-11

やりたかったこと

タイトル通りですが、SvelteKitPrismaで構成したアプリを Vercel にデプロイして動かしてみたところ、ページから API への通信が 404(Not Found) エラーで失敗していました。
SvelteKit はいわば、Next.js の Svelte 版で/routes以下に.(js|ts)ファイルを配置するとエンドポイントとして利用することができますが、ここへの通信が失敗していました。

解決方法

以下のようにpostbuildコマンドを package.json に追加する。

package.json
{
  "scripts": {
      ...
    "build": "svelte-kit build",
    + "postbuild": "cp prisma/schema.prisma .vercel_build_output/functions/node/render/ && cp node_modules/@prisma/engines/*query* .vercel_build_output/functions/node/render/",
      ...
  }
}

参考

https://github.com/sveltejs/kit/issues/1547
https://github.com/prisma/prisma/issues/7019

1
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
1
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?