|
1
|
If you see the following error in the Medusa Admin's console: |
|
2
|
|
|
3
|
```bash |
|
4
|
Blocked request. This host (X) is not allowed. To allow this host, add X to server.allowedHosts in vite.config.js. |
|
5
|
``` |
|
6
|
|
|
7
|
Where `X` is the host that's being blocked. For example, `example.com`. |
|
8
|
|
|
9
|
## Why this Error Occurred |
|
10
|
|
|
11
|
This error occurs if you deploy Medusa but are using development mode (`NODE_ENV=development`). This can happen accidentally or unintentionally, but Medusa defaults `NODE_ENV` to `production`. |
|
12
|
|
|
13
|
## How to Fix it |
|
14
|
|
|
15
|
### Option 1: Use Production Mode |
|
16
|
|
|
17
|
To resolve this error, ensure that you're running Medusa in production mode. You can set the `NODE_ENV` environment variable to `production` when starting Medusa: |
|
18
|
|
|
19
|
```bash |
|
20
|
NODE_ENV=production |
|
21
|
``` |
|
22
|
|
|
23
|
### Option 2: Allow the Host |
|
24
|
|
|
25
|
If you intentionally want to use development mode in your deployed Medusa instance, you can allow the host that's being blocked using the `admin.vite` configuration in `medusa-config.ts`. |
|
26
|
|
|
27
|
For example: |
|
28
|
|
|
29
|
```ts title="medusa-config.ts" |
|
30
|
module.exports = defineConfig({ |
|
31
|
// ... |
|
32
|
admin: { |
|
33
|
vite: () => { |
|
34
|
return { |
|
35
|
server: { |
|
36
|
allowedHosts: [".example.com"], |
|
37
|
}, |
|
38
|
} |
|
39
|
}, |
|
40
|
}, |
|
41
|
}) |
|
42
|
``` |
|
43
|
|
|
44
|
In the above example, you allow the host `example.com` to access the Medusa Admin. Make sure that when you replace `example.com` with your actual host, you include the leading `.` before the domain name. |
|
45
|
|
|
46
|
--- |
|
47
|
|
|
48
|
## Additional Resources |
|
49
|
|
|
50
|
- [Environment Variables](!docs!/learn/fundamentals/environment-variables) |
|
51
|
- [admin.vite Configuration](!docs!/learn/configurations/medusa-config#vite) |