Amin Setayeshfar
Amin Setayeshfar

Reputation: 908

How to redirect to a dynamic external URL in Angular universal?

I'm using angular(7) universal and i need to redirect user to an external url which i get from a web api. the problem is there is no window object in angular universal (i need the search engine bots to be redirected - meaning it is most important in server side) any help would be appreciated

Upvotes: 0

Views: 538

Answers (2)

Amin Setayeshfar
Amin Setayeshfar

Reputation: 908

as a more detailed answer after @MBDev answer here is how you can set the meta tag grammatically

constructor(private _meta: Meta){}
redirect(){
   this._meta.addTag({ 'http-Equiv': 'refresh', content: '0; '+this.redirectUrl });
}

Upvotes: 1

MBDev
MBDev

Reputation: 442

Try the following html header:

<meta http-equiv="refresh" content="0; url=https://mywebsite.test/" />

Upvotes: 1

Related Questions