#Medusa on Localhost giving 401

54 messages · Page 1 of 1 (latest)

lethal gazelle
#

I am setting up medusa backend and admin UI on localhost

The admin UI shows 401 errors in netwrok tab. The backend is running on port 9000. The UI is accessiable on port 7001.

Everything is setup on localhost. I am using .env file.

Node version: 18.20
Medusa version: 1.20.8

cosmic ocean
hallow dew
lethal gazelle
cosmic ocean
#

Did you possibly change the ADMIN_CORS variable?

#

Though you'd get a CORS error, not a 401 I think

#

I would try running medusa user -e [email protected] -p password with the CLI tools and see if you can manually add a new user

lethal gazelle
#

It's indeed 401, unathorized error. I used the cli to add new user, new user is added.

One more thing i want to know here. Is it normal behaviour of medusa admin ui, that it shows these error but after login it does not show this on AWS

cosmic ocean
#

Where does AWS come into the picture?

lethal gazelle
#

It was showing these error 401 unauthorized, then i thought it's may be due to cookie , so i setup aws instance with nginx with ssl certs

#

on localhost, i am getting these errors , while on AWS i can see these errors as well on login page, but i can login, while on localhost it's not loging in

cosmic ocean
#

What are you using for postgres? Might be a pointing to the wrong DB somewhere?

#

locally?

#

docker or actual install

lethal gazelle
#

Database is on AWS indeed the database is connected and migrations are applied to correct database

#

It's standalone installtion, because i want to dockerize it but as it's not working as standalone

cosmic ocean
#

It's kinda working for me with a lot of fiddling

lethal gazelle
#

can you tell me what is the default behaviour on login page, does network tab shows these error without login?

cosmic ocean
#

Yes, default behaviour is regular 401 for those batch job requests

#

Auth 401s are only if you try and fail to login

#

I'll just double check

lethal gazelle
#

let me share more with you, thank for the input

cosmic ocean
#

looks like it

lethal gazelle
cosmic ocean
#

getting an application error on that

lethal gazelle
#

Here what i see

cosmic ocean
#

I think unfortunately your backend has died but you're just seeing the UI cached

lethal gazelle
#

let me restart it

cosmic ocean
#

Which means the downstream service is unreachable

lethal gazelle
#

give me a moment,let me fix it

cosmic ocean
#

works for me, can login

lethal gazelle
#

I can also login but what about these errors in network tab?

#

Without login, i can see these

cosmic ocean
#

Are they old? Once I'm logged in they're all 200s. Clear the console log and then click around once logged in and you shouldn't see any 401s

lethal gazelle
cosmic ocean
#

Ah yes, these are completely normal. You want unauthorised people to be denied access

#

Though the batch requests I think is a bug, as it probably shouldn't be making those if you're not logged in

lethal gazelle
#

Any suggestions and improvements on the production setup?

lethal gazelle
cosmic ocean
#

I would edit the seed.json to remove the creation of the default user or just delete them from the DB

lethal gazelle
#

i will do that, anything else for production? i am using medusa start for production build

cosmic ocean
#

There's a big long list of what to do for productions and I still haven't got my project into production either. But here's some off the top of my head:

  • Setup regular DB backups
  • Understand how the migrations command works
  • Give at least 4GB of RAM to the instance running Medusa
  • Seperate out the Admin UI and don't server from the same server that's running Medusa (I've managed to get it running as a static deployment from a Google Storage Bucket with a bit of help from CloudFlare magic)
lethal gazelle
#

All of above are done, only left with medusa admin ui, i am also think to host them on s3 with cloudfront

#

But I am confused what is the default path for the static resource for admin ui

#

as medusa develop generate them

cosmic ocean
#

errgh yeah took me a far too long to figure out

lethal gazelle
#

I sent the DM to you. If you are ok please share it