title: Angular universal SSR dynamic absolute base-herf path
body: <p>Hey I have App based on this <a href="https://github.com/Angular-RU/angular-universal-starter/tree/5f0236c22e54004631304312aff36d15851930ad" rel="nofollow noreferrer">starter kit</a></p>
  
  <p>I deploy my app with the SSR feature from <code>server.ts</code>.</p>
  
  <p>and the app is being served "dynamically" with Apache reverse proxy to localhost:4002 for multiple domains.</p>
  
  <p>I.e
  <code>domainA.com</code>
  and <code>domainB.com</code> point to the same localhost:4002 with rev proxy.
  All the domains use the same App instance
  So far so good.</p>
  
  <p>But now I've got a requirement for it to work under our partner reverse proxy which will look something like this <code>partner.com/app/</code> will reverse proxy to <code>partner.domainA.com</code></p>
  
  <p>Which causes a lot of problems when loading the JS.</p>
  
  <p>Currently the base-href is set to <code>/</code> which works on our sites great.
  but when a user goes to <code>partner.com/app</code> the browser tries to load all the JS assets from <code>partner.com/*.js</code> while the are only available on <code>partner.com/app/*.js</code> or <code>partner.domainA.com/*.js</code>.</p>
  
  <p>My possible solution is to set <code>APP_BASE_HERF</code> from the server.ts when the request arrives.</p>
  
  <p>But every thing I tried didn't seem to work.</p>
  
  <p>I tried following this <a href="https://medium.com/@anandshende1994/setting-base-href-dynamically-in-angular-6-b7fe824848cf" rel="nofollow noreferrer">guide</a> but it didn't seem to work and it was loading the url from the <code>window</code>  object while I need to set it from the origin host which is available only from <code>req.headers.host</code> </p>
  
  <p>in <a href="https://github.com/Angular-RU/angular-universal-starter/blob/5f0236c22e54004631304312aff36d15851930ad/server.ts" rel="nofollow noreferrer">server.ts</a>:</p>
  
  <pre><code>  res.render(
  '../dist/index',
  {
    req: req,
    res: res,
    // provers from server
    providers: [
      // for http and cookies
      {
        provide: REQUEST,
        useValue: req,
      },
      {
        provide: RESPONSE,
        useValue: res,
      },
      /// for cookie
      {
        provide: NgxRequest,
        useValue: req,
      },
      {
        provide: NgxResponce,
        useValue: res,
      },
      // for absolute path
      {
        provide: 'ORIGIN_URL',
        useValue: `${http}://${req.headers.host}`,
      },
    ],
  },
  </code></pre>
  
  <p>is there a way to put the ORIGIN_URL in index.html base-herf?
  What is the correct way to set the base-herf in that way?</p>
  
  <p>Thanks</p>