Answer the question
In order to leave comments, you need to log in
Why doesn't the path change through the pathRewrite proxy parameter on Angular?
When using a proxy on angular, the pathRewrite parameter from the proxy.config.json file does not work. That is, the proxy process itself works, the desired page is loaded, but the url path does not change. Tell me, what could be the reason?
My code:
package.json
{
"name": "helloapp",
"version": "1.0.0",
"description": "First Angular 13 Project",
"author": "Mikhail Matveev",
"scripts": {
"ng": "ng",
"build": "ng build",
"start": "ng serve --proxy-config proxy.config.json"
},
"dependencies": {
"@angular/common": "~13.3.1",
"@angular/compiler": "~13.3.1",
"@angular/core": "~13.3.1",
"@angular/forms": "~13.3.1",
"@angular/platform-browser": "~13.3.1",
"@angular/platform-browser-dynamic": "~13.3.1",
"@angular/router": "~13.3.1",
"rxjs": "~7.4.0",
"zone.js": "~0.11.4"
},
"devDependencies": {
"@angular-devkit/build-angular": "~13.3.1",
"@angular/cli": "~13.3.1",
"@angular/compiler-cli": "~13.3.1",
"@types/node": "~14.0.0",
"typescript": "~4.4.4"
}
}
{
"version": 1,
"projects": {
"helloapp": {
"projectType": "application",
"root": "",
"sourceRoot": "src",
"architect": {
"build": {
"builder": "@angular-devkit/build-angular:browser",
"options": {
"outputPath": "../dist/helloapp",
"index": "src/index.html",
"main": "src/main.ts",
"polyfills": "src/polyfills.ts",
"tsConfig": "tsconfig.json",
"aot": true
}
},
"serve": {
"builder": "@angular-devkit/build-angular:dev-server",
"options": {
"browserTarget": "helloapp:build",
"proxyConfig": "proxy.config.json"
}
}
}
}},
"defaultProject": "helloapp"
}
{
"/dist/*": {
"target": "https://www.youtube.com/",
"secure": false,
"pathRewrite": {
"^/dist": "https://www.youtube.com/"
},
"logLevel": "debug",
"changeOrigin": true
}
}
Answer the question
In order to leave comments, you need to log in
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question