#Has anyone successfully deployed Medusa to Railway/Vercel?
4 messages · Page 1 of 1 (latest)
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.
Yes, that's correct. However, what would be the best way to set up the environment in this case? We tried using process.env.MEDUSA_BACKEND_URL and process.env.NEXT_PUBLIC_MEDUSA_BACKEND_URL, but it seems that /admin is unable to read the .env file.
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