Help i need to get my custom domain to fetch store config but when I try to use the url on the server side is showing me the cloud function url, not the url that the user typed in. example: my user types in the browser https://test-url.mybuss.co/ Hosting redirects to functions (i.e. https://us-east1-blablabla.com/) functions renders my html this includes making some http calls to my API BUT I have two ways to recognize which company is trying to check my store
First one query params https://test-url.mybuss.co/myStore I sent myStore as a query parameter and success second case https://test-url.mybuss.co/ I sent the host url as a parameter and success BUT whenever I'm on server side instead of sending this URL(https://test-url.mybuss.co/) the express server catches the cloud function url. Any ideas?
I've tried every host parameter
console.log(req.headers.host);
console.log(req.hostname);
console.log(req.host); // even this deprecated one
console.log(req.subdomains)
and they all give me the same result https://us-east1-blablabla.com/
Tried using platformLocation and also tried this solution right here
req.get('host')
So the solution to my answer was using the parameter x-fowarded-Host Which I obtained by req.get('x-forwarded-Host') And transfered through providers
res.render(indexHtml, {
req, providers: [
{ provide: APP_BASE_HREF, useValue: req.baseUrl },
{ provide: 'ORIGIN_URL', useValue: req.get('x-forwarded-Host') },
]
});
I also had to include these lines app.server.module.ts
@NgModule({
imports: [
AppModule,
ServerModule,
ServerTransferStateModule,
],
app.module.ts
imports: [
BrowserTransferStateModule
],
to retrieve the data in my resolver I had to include this variable in my constructor
@Optional() @Inject('ORIGIN_URL') public urlOrigin: string