Better-Auth, Polar, and Vercel deployment error
While deploying to Vercel using Better-Auth with Polar, I am getting this warning:
And my app doesn't work, I am just getting 500 international server, how to fix that? It all works in my localhost.
I use like this:
Without
it works in the prod.
2025-08-05T00:55:05.833Z Run npm run preview to preview your production build locally.
2025-08-05T00:55:05.838Z
2025-08-05T00:55:05.838Z > Using @sveltejs/adapter-auto
2025-08-05T00:55:24.468Z Warning: The following modules failed to locate dependencies that may (or may not) be required for your app to work:
2025-08-05T00:55:24.468Z node_modules/@polar-sh/better-auth/dist/index.js
2025-08-05T00:55:24.468Z - /vercel/path0/node_modules/@polar-sh/sdk/dist/esm/webhooks.ts.js
2025-08-05T00:55:24.469Z node_modules/@polar-sh/better-auth/dist/index.cjs
2025-08-05T00:55:24.469Z - @polar-sh/sdk/webhooks.ts
2025-08-05T00:55:24.469Z node_modules/node-fetch/lib/index.js
2025-08-05T00:55:24.469Z - encoding
2025-08-05T00:55:24.796Z ✔ done
2025-08-05T00:55:26.508Z Build Completed in /vercel/output [1m]
2025-08-05T00:55:27.045Z Deploying outputs...
2025-08-05T00:55:35.756Z Deployment completed
2025-08-05T00:55:05.833Z Run npm run preview to preview your production build locally.
2025-08-05T00:55:05.838Z
2025-08-05T00:55:05.838Z > Using @sveltejs/adapter-auto
2025-08-05T00:55:24.468Z Warning: The following modules failed to locate dependencies that may (or may not) be required for your app to work:
2025-08-05T00:55:24.468Z node_modules/@polar-sh/better-auth/dist/index.js
2025-08-05T00:55:24.468Z - /vercel/path0/node_modules/@polar-sh/sdk/dist/esm/webhooks.ts.js
2025-08-05T00:55:24.469Z node_modules/@polar-sh/better-auth/dist/index.cjs
2025-08-05T00:55:24.469Z - @polar-sh/sdk/webhooks.ts
2025-08-05T00:55:24.469Z node_modules/node-fetch/lib/index.js
2025-08-05T00:55:24.469Z - encoding
2025-08-05T00:55:24.796Z ✔ done
2025-08-05T00:55:26.508Z Build Completed in /vercel/output [1m]
2025-08-05T00:55:27.045Z Deploying outputs...
2025-08-05T00:55:35.756Z Deployment completed
<script lang="ts">
import { goto } from "$app/navigation";
import { authClient } from "$lib/client/utils/rpc";
import { polarProductIdsEnvConfig } from "$lib/shared/utils/env-config";
async function handleCheckout() {
await authClient.checkout({
products: [polarProductIdsEnvConfig.pro]
});
}
</script>
<div class="absolute top-1/3 left-1/2 -translate-x-1/2 -translate-y-1/2">
<button class="btn" onclick={() => goto("/auth")}>Auth</button>
<button class="btn" onclick={handleCheckout}>Checkout</button>
</div>
<script lang="ts">
import { goto } from "$app/navigation";
import { authClient } from "$lib/client/utils/rpc";
import { polarProductIdsEnvConfig } from "$lib/shared/utils/env-config";
async function handleCheckout() {
await authClient.checkout({
products: [polarProductIdsEnvConfig.pro]
});
}
</script>
<div class="absolute top-1/3 left-1/2 -translate-x-1/2 -translate-y-1/2">
<button class="btn" onclick={() => goto("/auth")}>Auth</button>
<button class="btn" onclick={handleCheckout}>Checkout</button>
</div>
async function handleCheckout() {
await authClient.checkout({
products: [polarProductIdsEnvConfig.pro]
});
}
async function handleCheckout() {
await authClient.checkout({
products: [polarProductIdsEnvConfig.pro]
});
}
Solution:Jump to solution
Adding this to my
vite.config.ts
worked:
```js
import { sveltekit } from "@sveltejs/kit/vite";
import tailwindcss from "@tailwindcss/vite";...1 Reply
Solution
Adding this to my
vite.config.ts
worked:
import { sveltekit } from "@sveltejs/kit/vite";
import tailwindcss from "@tailwindcss/vite";
import { defineConfig } from "vite";
export default defineConfig({
plugins: [tailwindcss(), sveltekit()],
ssr: {
noExternal: ["@polar-sh/sdk", "@polar-sh/better-auth"]
},
optimizeDeps: {
exclude: ["@polar-sh/sdk/webhooks.ts"]
}
});
import { sveltekit } from "@sveltejs/kit/vite";
import tailwindcss from "@tailwindcss/vite";
import { defineConfig } from "vite";
export default defineConfig({
plugins: [tailwindcss(), sveltekit()],
ssr: {
noExternal: ["@polar-sh/sdk", "@polar-sh/better-auth"]
},
optimizeDeps: {
exclude: ["@polar-sh/sdk/webhooks.ts"]
}
});