#Medusa admin not working properly with NODE_ENV=production

3 messages · Page 1 of 1 (latest)

viscid crest
#

Hello. I am configuring a medusa instance with backend + back office together on production mode.

  • I set the NODE_ENV to production.
  • I have set the .env.production identical to the .env
  • I build and start the medusa project

Until this, it is fine. But when the admin dashboard is ready. If I try to log in, it process then goes back to admin log-in page. The backend logs says 401 unauthorized, but the super user is properly set.

the url is http://localhost:9000/app/login so I believe there is not a problem CORS.

I tried to set the NODE_ENV=development and it works properly.

N.B :

  • The database is properly configured
  • the curl http://localhost:9000/health works on every case (development or production NODE_ENV)
  • Medusa version : "@medusajs/medusa": "^1.20.6"
  • Admin version : "@medusajs/admin": "^7.1.14"

Here is an example of the two commands I run :

NODE_ENV=production yarn run build
NODE_ENV=production npx medusa start&

Do you have an idea on what is going on ?

sinful musk
#

I had something similar, and I managed to solve it because basically within my nginx config I wasn’t setting some Proxy headers which were mandatory for the « https » that is required when you switch to production env since the session cookie will have the «secure » parameter to true

#

I hope this will help you