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

@@ -8,7 +8,7 @@ You might see a log in your browser console, that looks like this:
![CORS error log](https://res.cloudinary.com/dza7lstvk/image/upload/v1668003322/Medusa%20Docs/Other/jnHK115_udgf2n.png)
In your `medusa-config.js` , you should ensure that you've configured your CORS settings correctly. By default, the Medusa starter runs on port `9000`, Medusa Admin runs on port `7000`, and the storefront starters run on port `8000`.
In your `medusa-config.js` , you should ensure that you've configured your CORS settings correctly. By default, the Medusa starter runs on port `9000`, Medusa Admin runs on port `7001`, and the storefront starters run on port `8000`.
The default configuration uses the following CORS settings:
@@ -7,7 +7,7 @@ import OtherErrors from './create-medusa-app-errors/_other-errors.mdx'
import InvalidTokenError from './create-medusa-app-errors/_no-browser-token-error.md'
import DockerSection from "./database-errors/_docker.md"
import DbUrlError from './create-medusa-app-errors/_db-url-error.md'
import PortError from './create-medusa-app-errors/_port.md'
import ForwardingError from './create-medusa-app-errors/_forwarding.md'
## TypeError: cmd is not a function
@@ -15,9 +15,9 @@ import PortError from './create-medusa-app-errors/_port.md'
---
## Admin Login or User Errors
## Errors when using VSCode or GitHub Codespaces
<PortError />
<ForwardingError />
---
@@ -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.
@@ -14,5 +14,5 @@ port: 9000
This means that there's another process running at port `9000`. You need to either:
- Change the default port used by the Medusa backend. You can do that by setting the `PORT` environment variable to a new port. When you do this, make sure to change the port used in other apps that interact with your Medusa backend, such as in your [admin](../admin/configuration.md#build-command-options) or [storefront](../starters/nextjs-medusa-starter.mdx#changing-medusa-backend-url).
- Change the default port used by the Medusa backend. You can do that by setting the `PORT` environment variable to a new port. When you do this, make sure to change the port used in other apps that interact with your Medusa backend, such as in your [admin](../admin/configuration.mdx#build-command-options) or [storefront](../starters/nextjs-medusa-starter.mdx#changing-medusa-backend-url).
- Terminate other processes running on port `9000`.