medusajs / medusa

The world's most flexible commerce platform.
https://medusajs.com
MIT License
26.24k stars 2.67k forks source link

MEDUSA_BACKEND_URL from .env file gets overwritten so admin always uses localhost:9000 #7069

Closed dmiric closed 7 months ago

dmiric commented 7 months ago

Bug report

Describe the bug

MEDUSA_BACKEND_URL from .env file gets overwritten so admin always uses localhost:9000

Additional context

I'm trying to split admin UI and backend to two different servers, admin UI is always sending requests to localhost:9000 no matter how I change .env variables or code in medusa-config.ts

According to documentation: https://docs.medusajs.com/cli/reference#develop I should be able to pass --host argument in --host but that arguments seems to be completely ignored.

toooo commented 7 months ago

when developing on eg. Github Codespace then 'medusa develop' uses hardcoded localhost https://github.com/medusajs/medusa/blob/c3efac5a0d6cfa38e1af8d248138fa83934a8ceb/packages/medusa/src/commands/develop.js#L79

Maybe connected with this https://github.com/medusajs/medusa/pull/5022

https://github.com/medusajs/medusa/issues/5616#issuecomment-1820144427

Maybe there are other places where localhost is hardcoded in admin-ui build chain?

dmiric commented 7 months ago

Yes hard coded localhost in develop.ts is where localhost comes from. I managed to sort it out by building admin separately with the same command that is used in develop.ts, but it would be better if that would be pulled from .env file.

shahednasser commented 7 months ago

Issue has been fixed in PR #7128 and will be part of the next release.