Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/angular/30.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/6/apache/8.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Angular 使用RenderRon时,基本路线始终为空_Angular_Apache_Proxy_Rendertron - Fatal编程技术网

Angular 使用RenderRon时,基本路线始终为空

Angular 使用RenderRon时,基本路线始终为空,angular,apache,proxy,rendertron,Angular,Apache,Proxy,Rendertron,我一直在尝试通过apache代理使用rendertron,但是所有的基本路由都是“null”,是否有可能是我犯了一些配置错误?如果你能帮助我,我将不胜感激 Rendertron正在默认情况下具有的端口3000上运行。apache主机是这样的: <VirtualHost *:80> ServerName render.vool.xyz ProxyRequests Off <Proxy *> #Require all grant

我一直在尝试通过apache代理使用rendertron,但是所有的基本路由都是“null”,是否有可能是我犯了一些配置错误?如果你能帮助我,我将不胜感激

Rendertron正在默认情况下具有的端口3000上运行。apache主机是这样的:

<VirtualHost *:80>
        ServerName render.vool.xyz
        ProxyRequests Off

  <Proxy *>
     #Require all granted
     Order deny,allow
     Allow from all
  </Proxy>

  <Location />
        ProxyPass http://localhost:3000/
        ProxyPassReverse http://localhost:3000/
        Header set Access-Control-Allow-Origin "http://render.vool.xyz"
  </Location>
</VirtualHost>

ServerName render.vool.xyz
代理请求关闭
#要求所有授权
命令拒绝,允许
通融
ProxyPasshttp://localhost:3000/
ProxyPassReversehttp://localhost:3000/
标题集访问控制允许原点“http://render.vool.xyz"
Rendertron服务已启动并在render.vool.xyz url中运行


再次感谢

我可以检测到与初始化中的协议相对应的斜杠已从url中删除

this.app.use(
       route.get('/render/:url(.*)', this.handleRenderRequest.bind(this)));
我通过在RenderRon类中添加以下方法并从handleRenderRequest方法调用它来解决这个问题

handleFixProtocol(href: string) {
    if (href.startsWith('https://') || href.startsWith('https://') ) {
      return href;
      } else {
        const parsedUrl = url.parse(href);
        if (!parsedUrl.host) {
          return parsedUrl.protocol + '/' + parsedUrl.path;
        } else {
          return parsedUrl.protocol + '//' + parsedUrl.host + parsedUrl.path;
        }
    }
   }
async handleRenderRequest(ctx: Koa.Context, url: string) {
    if (!this.renderer) {
      throw (new Error('No renderer initalized yet.'));
    }

    url = this.handleFixProtocol(url);