管理面板自定义:主机、端口和路径配置
¥Admin panel customization: Host, port, and path configuration
默认情况下,Strapi 的 管理面板 通过 [http://localhost:1337/admin](http://localhost:1337/admin) 公开。出于安全原因,可以更新主机、端口和路径。
¥By default, Strapi's admin panel is exposed via http://localhost:1337/admin. For security reasons, the host, port, and path can be updated.
仅更新管理面板的路径
¥Update the admin panel's path only
除非你选择在不同的服务器上部署 Strapi 的后端服务器和管理面板服务器(参见 deployment),否则默认情况下:
¥Unless you chose to deploy Strapi's back-end server and admin panel server on different servers (see deployment), by default:
-
Strapi 的后端服务器和管理面板服务器都在同一主机和端口上运行,即
http://localhost:1337/。¥The back-end server and the admin panel server of Strapi both run on the same host and port, which is
http://localhost:1337/. -
管理面板可通过
/admin路径访问,而后端服务器可通过/api路径访问。¥The admin panel is accessible at the
/adminpath while the back-end server is accessible at the/apipath.
要使管理面板可从其他路径访问,例如 http://localhost:1337/dashboard,请在 管理面板配置文件 中定义或更新 url 属性,如下所示:
¥To make the admin panel accessible at another path, for instance at http://localhost:1337/dashboard, define or update the url property in the admin panel configuration file as follows:
module.exports = ({ env }) => ({
// … other configuration properties
url: "/dashboard",
});
由于默认情况下后端服务器和管理面板服务器在同一主机和端口上运行,因此如果你在 服务器配置 文件中保留 host 和 port 属性值不变,则仅更新 config/admin.[ts|js] 文件应该有效,如下所示:
¥Since by default the back-end server and the admin panel server run on the same host and port, only updating the config/admin.[ts|js] file should work if you left the host and port property values untouched in the server configuration file, which should be as follows:
- JavaScript
- TypeScript
module.exports = ({ env }) => ({
host: env("HOST", "0.0.0.0"),
port: env.int("PORT", 1337),
});
export default ({ env }) => ({
host: env("HOST", "0.0.0.0"),
port: env.int("PORT", 1337),
});