[英]How to migrate angular-fullstack app to a domain with a base URL
I have a fairly complicated issue in that I originally developed a MEAN app with the Yeoman fullstack-angular generator with no base URL. 我有一个相当复杂的问题,因为我最初是使用Yeoman Fullstack-Angular生成器开发的MEAN应用程序,没有基本URL。 In development http://localhost:9000/ worked just fine.
在开发中, http:// localhost:9000 /正常工作。
Moving into production, I'm using a reverse Apache proxy with a particular path example.com/foo to serve http://localhost:9000 . 进入生产阶段,我正在使用带有特定路径example.com/foo的反向Apache代理来提供http:// localhost:9000 。 Now when I load up example.com/foo I get a bunch of 404 errors (of course) because eg example.com/app, example.com/bower_components don't exist.
现在,当我加载example.com/foo时,我会收到一堆404错误(当然),因为例如example.com/app、example.com/bower_components不存在。
I'm a little out of my league here and no where to start, is there some Express/Angular/etc config variables I should be looking at to help with this migration? 我在这里有点陌生,没有起点,我应该寻找一些Express / Angular / etc配置变量来帮助进行迁移吗?
server/config/express.js yielded no hints and I can't find anything in the Grunt file to make wiredep compile the correct links. server / config / express.js没有任何提示,我在Grunt文件中找不到任何东西可以使Wiredep编译正确的链接。 Or maybe there is even a way to do this in Apache...
或者也许甚至有一种方法可以在Apache中执行此操作...
To clarify, the issue was that I need to deploy a MEAN app behind a base URL /foo. 为了澄清,问题是我需要在基本URL / foo后面部署MEAN应用。 Do that I:
我这样做:
1) Used the following Apache rules: 1)使用了以下Apache规则:
RewriteEngine on
RewriteRule ^/foo/(.*)$ http://localhost:9000/$1 [P]
2) Now we just need to just make all requests go to example.com/foo/whatever. 2)现在,我们只需要将所有请求发送到example.com/foo/whatever。 Edit the base tag in index.html to be:
将index.html中的基本标记编辑为:
<base href="/foo/" />
3) Made all hrefs and service calls relative instead of absolute (Angular providers works with the <base>
tag) 3)使所有href和服务调用相对而不是绝对(Angular提供程序与
<base>
标记一起使用)
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.