'Prevent Flask from changing the url from '/home' to '/static/home'
The app runs only when I build the angular project using ng build --base-href=/static/ but then http://127.0.0.1:5000/home automatically changes to http://127.0.0.1:5000/static/home and the rest of my routes fail, even a refresh button fails as /static/ route does not exist in my angular routing.
app-routing.module.ts
{ path: 'home', component: HomeComponent },
{ path: 'demo', component: DemoComponent },
{ path: '**', redirectTo: 'home' }
index.html
<base href="/">
angular.json
"root": "",
"sourceRoot": "src",
"prefix": "app",
"architect": {
"build": {
"builder": "@angular-devkit/build-angular:browser",
"options": {
"outputPath": "../static/",
"index":{
"input": "src/index.html",
"output": "../templates/index.html"
}
server.py
app = Flask(__name__)
@app.route('/')
def root():
return render_template('index.html')
@app.route("/home")
def home():
return render_template('index.html')
if __name__ == '__main__':
app.run(port=5000, debug=True)
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|
