url params not making it to my landing page with angular app

30 Views Asked by At

when testing on localhost everything works great:

http://localhost:4200/#/?referralId=1

the url stays in the bowser and I am able to access my params. But when I upload the app to the server and I go to this url:

https://www.betradating.com?referralId=1

the browser is refreshing automatically, losing the params and displaying:

https://www.betradating.com/#

How can I fix this?

2

There are 2 best solutions below

0
kflo411 On

http://localhost:4200/#/?referralId=1

It looks like you're using HashLocationStrategy?

https://www.betradating.com?referralId=1

You must add a <base href> element to the application's index.html for this type of HTML5 routing to work (pushState routing).

Add the <base> element within the <head> tag:

<head>
  <meta>...
  <title>...
  <base href="/">
0
Rick On

turns out I needed the hash character in the url for it to work:

https://www.betradating.com/#/?referralId=1