Reputation: 667
I currently have a link in my html/css page that links to https://domain_name/route, which will take me to the actual website that is currently deployed on the internet. However, when I run the application locally, the link will change to localhost:7364/home, and since the link is hardcoded it will still link to the application that is running online. Is there a way to change this link so that it will change the appropriate link whether it's running locally or online (in AWS)? I know in node there is a property of the request object (headers.host) that I can pass into the html page, but ideally I'd like a solution that can just stick with html/css (and perhaps javascript) on the page.
The page runs via ejs so I'm wondering if there's a way to check within the page if it's running locally or online, and use an if statement to change the link? (without passing values into the page via node)
Upvotes: 1
Views: 286
Reputation: 3135
you can check window.location
and then change the href attribute.
Assuming your anchor is like this
<a href="aws.com/yourlink">The link</a>
Next in your code check where you are operating
if(window.location.host.indexOf('aws.com') {
//modify your link href
}
Upvotes: 1