docs: improve admin documentation (#6117)

- Move the admin plugin's options to the Admin Configuration documentation.
- Add a section on how to change the backend URL for both development and production.
- Fix the troubleshooting section related to port forwarding.
- General fixes.
This commit is contained in:
Shahed Nasser authored and GitHub committed 2024-01-22 15:48:33 +00:00
1 parent b61acf9312
commit 8c67e32d41
15 files changed
+370 -149

No files matched your search

@@ -0,0 +1,13 @@
If you're running the Medusa backend through tools like VSCode or GitHub Codespaces, you must ensure that:
1. Port forwarding is configured for ports `9000` and `7001`. Refer to the following resources on how to configure forwarded ports:
1. [VSCode local development.](https://code.visualstudio.com/docs/editor/port-forwarding)
2. [VSCode remote development.](https://code.visualstudio.com/docs/remote/ssh#_forwarding-a-port-creating-ssh-tunnel)
3. [GitHub Codespaces.](https://docs.github.com/en/codespaces/developing-in-a-codespace/forwarding-ports-in-your-codespace)
2. If your tool or IDE exposes an address other than `localhost`, such as `127.0.0.1`, make sure to add that address to the [admin_cors](../../development/backend/configurations.md#admin_cors-and-store_cors) Medusa configuration. Your tool will show you what the forwarded address is.
After setting these configurations, run your Medusa backend and try again. If you couldn't create an admin user before, run the following command in the root directory of your Medusa project to create an admin user:
```bash
npx medusa user -e admin@medusa-test.com -p supersecret
```
@@ -1,10 +0,0 @@
By default, the Medusa backend runs on `localhost:9000`. However, the port may change based on the `PORT` environment variable.
If you run the `create-medusa-app` command, and the installation finishes successfully, but the backend runs on a different port than `9000`, it may cause errors when you try to create an admin user or login during the onboarding process. This could either be because you have the `PORT` environment variable set to something differnt, or because of port forwarding.
To resolve this, you must:
1. Terminate the `create-medusa-app` process and change to the new backend's directory.
2. Either explicitely set the `PORT` environment variable to `9000`, or set the environment variable `MEDUSA_ADMIN_BACKEND_URL` to the backend's URL. For example, if the backend is running on `localhost:7000`, change the `MEDUSA_ADMIN_BACKEND_URL` to `http://localhost:7001`. This ensures that the admin uses the correct port. In case of port fowarding, it's recommended to explicitely set the `PORT` environment variable.
3. Create an admin user using the [user command of the CLI tool](../../cli/reference.mdx#user).
4. Start the backend again either with the `dev` command of the backend project or using `npx medusa develop` and try to login again.