#Cannot login to Medusa Admin on self-hosted server

22 messages · Page 1 of 1 (latest)

slim current
#

Hello People!

I cannot login to Medusa Admin on self-hosted server (VPS: Ubuntu, apache2, nginx, node18).

I have opened ports 9000 and 7000 (server and admin respectively) on Apache2 reverse proxy and have run, without problem, both processes:

"✔ Server is ready on port: 9000 - 17ms".
"VITE v3.2.5 ready in 636 ms.

➜ Local: http://localhost:7000/"

However, at the login screen I am unable to proceed. I use the data created with --seed as well as an account I created but I get "These credentials do not match our records".

The browser shows me "ERR_CONNECTION_REFUSED" in auth and store/ (xhr)

My .env is in "production" and I have the CORS variable set. I also have Minio running and can login without problems.

ANY help is welcome.

fallen wedge
#

What is displayed on the console network ?

fallen wedge
slim current
fallen wedge
#

That thread is mainly a solution for production, to troobleshoot the error you are facing I need to know if it's in localhost or production

slim current
fallen wedge
#

How does look your this part of your vite.config.ts ?

define: {
    __MEDUSA_BACKEND_URL__: JSON.stringify(
      env.MEDUSA_BACKEND_URL ||
        // Backwards-compat with Gatsby.
        env.GATSBY_MEDUSA_BACKEND_URL ||
        env.GATSBY_STORE_URL ||
        ""
    ),
  },
#

Did you created a .env file at the root of the Admin ?

slim current
# fallen wedge How does look your this part of your vite.config.ts ? ``` define: { __MEDUSA...

My vite.config.ts:

define: {
MEDUSA_BACKEND_URL: JSON.stringify(
env.MEDUSA_BACKEND_URL ||
// Backwards-compat with Gatsby.
env.GATSBY_MEDUSA_BACKEND_URL ||
env.GATSBY_STORE_URL ||
""
),
},

No .env file on /Admin but /Server includes .env.production with:

ADMIN_CORS=https://domain.com
MEDUSA_BACKEND_URL=https://domain.com
NEXT_PUBLIC_MEDUSA_BACKEND_URL=https://domain.com
VITE_MEDUSA_BACKEND_URL=https://domain.com

fallen wedge
#

I used this and it's not working

#

When I change src/srvices/config.js with the right url it works but I get a 401 error

fickle hearth
#

Does it work on your local machine?

#

Also you're running this on a remote server and are you're trying to reach localhost?

#

In production Vite shouldn't be running in dev mode

slim current
#

With the modifications I have made based on @fallen wedge 's recommendations the results have improved (Chrome Console/Network tabs now show the domain and not "localhost") but I still can't log in (GET 404 in "store/" or "auth/").

Could I have missed something when switching to production mode? I have also thought that it could be something to do with nginx and the way it works with React but I haven't found anything wrong.

fallen wedge
#

So according to me you changed the file src/services/config.js like in the new thread I've opened

#

I have the same problem then I can't login in Admin