自定义域而不是本地主机 - Angular

Sat*_*hia 11 angular custom-domain

开发目的我想使用自定义域而不是启动我的 Angular 应用程序localhost

还有其他办法吗?

我能够找到php的解决方案,但没有找到Angular 应用程序的解决方案。

Vik*_*kas 14

更新您的angular.json

这是你应该做的:

"projects": {
    "project-name": {
        ...
        "architect": {
            "serve": {
                "options": {
                  "host": "customdomain.baz",
                  "port": 80
                }
            }
        }
    }
}
Run Code Online (Sandbox Code Playgroud)

如果您使用的是 mac/linux,请更新您的主机文件

/etc/hosts

##
##
# Host Database
#
# localhost is used to configure the loopback interface
# when the system is booting. Do not change this entry.
##
127.0.0.1       customdomain.baz // or whatever your domain is
255.255.255.255 broadcasthost
::1             localhost
Run Code Online (Sandbox Code Playgroud)