【问题标题】:Configure .htaccess file for a mean stack application为平均堆栈应用程序配置 .htaccess 文件
【发布时间】:2019-01-22 05:16:40
【问题描述】:

我正在将我的平均堆栈 Web 应用程序部署在支持 nodejs 的共享 a2 主机上。
我必须使用以下示例重新配置 .htaccess 文件以使用前端端口将用户重新路由到 localhost:

RewriteEngine On
RewriteRule ^$ http://127.0.0.1:55555/ [P,L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ http://127.0.0.1:55555/$1 [P,L]

网站建议使用 49152 到 65535(含)之间的端口。
我将端口 55555 用于前端,将 50000 用于后端,但我需要配置 .htaccess 来路由后端请求,就像它与前端一样,因为现在网站仅作为前端项目打开,前端和后端之间没有连接。

【问题讨论】:

    标签: apache .htaccess web-deployment


    【解决方案1】:

    问题出在 Angular 代理配置中。Angular 需要配置为使用代理将后端请求从相对路径“/api/”路由到后端端口“localhost:port/api/”。
    您可以参考此链接了解如何操作。

    https://medium.freecodecamp.org/the-best-ways-to-connect-to-the-server-using-angular-cli-b0c6b699716c

    希望对你有帮助。

    【讨论】:

      猜你喜欢
      • 2018-07-13
      • 2017-09-05
      • 1970-01-01
      • 2017-11-28
      • 2018-02-15
      • 2016-11-25
      • 1970-01-01
      • 2014-05-21
      • 2016-04-08
      相关资源
      最近更新 更多