Search code examples
next.jsdigital-oceanmedusajs

MedusJs admin giving 401 status on every request


I recently deployed my medusaJs project on digital ocean. the deployment was successful and the backend endpoints are return the necessary JSON information when I hit them with a status of 200. How ever when I try to use my admin panel all my requests in my network tab have a status of 401 and the response is unauthorized. Has anyone encountered the same issue and is their a fix for it?


Solution

  • in that case you either have problem with CORS on your backend so try change it to this according to medusajs docs :

    ADMIN_CORS=/http:\/\/*/
    

    and add MEDUSA_ADMIN_BACKEND_URL which specify the backend url that the requests are send to :

    MEDUSA_ADMIN_BACKEND_URL=http://example.domain.com
    

    medusajs docs

    You can add the following options to the medusa-admin dev command:

    • --backend or -b: a string specifying the URL of the Medusa backend. By default, it's the value of the environment variable MEDUSA_ADMIN_BACKEND_URL. For example, medusa-admin dev --backend example.com .

    • --port or -p: the port to run the admin on. By default, it's 7001. For example, medusa-admin dev --port 8000.