I'm working on a angular web project where I have a angular site which communicates with a web api that uses a SQLlite database.
as I am new to angular, now I'm encountering a error where request are sent to the wrong port even though my proxy config is set to the api's port , where do I set the proper routing for traffic between my site and api/database.
The error I'm encountering while sending request:
Http failure response for http://localhost:4200/api/Account/AuthenticateUser: 404 Not Found
my proxy config:
{
"/api": {
"target": "http://localhost:44366/",
"secure": false,
"changeOrigin": true,
"logLevel": "debug"
}
}
sqllite: enter image description here
Note: I'm continuing work from a pre existing project
CodePudding user response:
Use like :
const routes: Routes = [ { path: '', component: StartScreenComponent, pathMatch: "full" }, { path: 'login', component: LoginComponent }, { path: 'welcome', component: WelcomeComponent }, ]
CodePudding user response:
In screenshot you attached that port you tried to use is set on https:// and here you are setting the http - that's the first thing.
Second one is how you run your app - could you please provide the command you use?
// EDIT
If you want to use https try as below:
{
"/api": {
"target": {
"host": "localhost",
"protocol": "https",
"port": 44366
},
"secure": false,
"logLevel": "debug"
}
}
and run it with a command:
ng serve --proxy-config ${your-proxy-file-name}.json --open --host 0.0.0.0 --disable-host-check
CodePudding user response:
This problem was fixed by running the app in visual studio in release mode instead of debug mode