How to set base url for Angular application
Better to do it when you build project. Like this:
ng build --prod --base-href=/test/
You can modify it using <base href="/">
in src/index.html
file.
<!doctype html>
<html lang="en">
<head>
<meta charset="utf-8">
<title>SiteFrontend</title>
<base href="/test"> //<------ this line
<meta name="viewport" content="width=device-width, initial-scale=1">
<link rel="icon" type="image/x-icon" href="favicon.ico">
</head>
<body>
<app-root></app-root>
</body>
Please follow these following steps:
- Set
useHash: false
inapp-routing-module.ts
- In
index.html
, change<base href="./" />
to<base href="/" />