#Has anyone successfully deployed Medusa to Railway/Vercel?

4 messages · Page 1 of 1 (latest)

left gust
#

I'm trying to fetch data from an API on a custom admin route, but it only works when I use the full backend URL. /admin/get-subs works locally, but not in production. I’ve tried using environment variables, but that doesn't seem to work either.

deft harbor
#

Not sure if am understanding you question 100% - but locally the admin and the server is on the same server instance, so it makes sense that fetch("/admin/get-subs") works, because its on the same server. When you deploy your server to Railway and your admin dashboard to Vercel then they aren't on the same server anymore, so now you need to type out the full URL in order for request to go to the right place.

left gust
deft harbor
#

It's a Vite application not a Next.js app, in Vite if you want to inject env variables into the bundle you need to prefix them with VITE_, and you access them like this: import.meta.env.VITE_BACKEND_API_URL

https://vite.dev/guide/env-and-mode

vitejs

Next Generation Frontend Tooling