【问题标题】:Make Lite-Server run as localhost:3000/parentdirectory and accessible as localhost/parentdirectory使 Lite-Server 作为 localhost:3000/parent 目录运行,并可作为 localhost/parent 目录访问
【发布时间】:2016-07-06 15:50:45
【问题描述】:

我有一个具有这种文件结构的 Angular2 应用程序:

  • 父目录
    • 应用程序目录
      • 应用程序
        • app.component 等
      • 节点模块
        • @angular
        • 精简版服务器
      • index.html
      • styles.css

我正在使用 lite-server 测试应用程序,它在 localhost:3000 上运行良好。为了使它与我正在设置的 Apache 代理一起工作,我需要它作为 locahost:3000/parentdirectory 运行。

使用角度路由,我可以轻松地让我的页面看起来像是来自 localhost:3000/parentdirectory,但这只是表面上的修复。如果我去 localhost/parentdirectory,它仍然需要工作。

我看了这个问题,觉得很像:Can't change the base folder for lite-server in Angular 2 application

但是,我对这一切都不熟悉,我害怕破坏我目前的工作设置。

我的直觉是我需要将我的 lite-server 移动到父目录并更改根文件夹以查看我的应用程序目录,但我不确定这是否真的能解决我的问题。

我希望有人可以给我具体的说明或文档链接,概述在我开始盲目更改之前我需要做些什么来完成这项工作。

谢谢!

【问题讨论】:

    标签: angular lite-server


    【解决方案1】:

    请尝试以下假设您的应用程序现在位于 app 文件夹中并且服务器在其上启动。即https://localhost:3000/app 1. index.html 设置<base href='/app/' /> 2.在引导{provide: APP_BASE_HREF, useValue: '/app/'} // import it from router package 3.在system.config.ts中添加baseURL: /app/

    【讨论】:

    • 感谢您的建议。这似乎会影响我的应用程序在哪里查找其文件,但不会影响 lite-server 的运行位置。效果是一个错误,即:GET localhost:3000/app/app 404 (Not Found)。我也尝试使用“/appdirectory/”名称而不是“app”,但结果相同。
    • 从父目录开始点亮服务器
    猜你喜欢
    • 1970-01-01
    • 2015-12-01
    • 1970-01-01
    • 2021-02-09
    • 1970-01-01
    • 2020-05-21
    • 2014-12-20
    • 2010-10-07
    • 2014-01-23
    相关资源
    最近更新 更多