Issue
"/api/*": {
"target": "https://localhost:8000/api",
"secure": false,
"logLevel": "debug",
"pathRewrite": {
"^/api": ""
},
"changeOrigin": true
}
Please provide detailed use of each feature in this code snippet
thank you for help
Solution
"/api/*": {
"target": "https://localhost:8000",
"secure": false,
"logLevel": "debug",
"pathRewrite": {
"^/api": ""
},
"changeOrigin": true
}
target:"api/*"
:
All requests made to/api/
from within your application will be forwarded totarget": "https://localhost:8000/api
"secure": false,
:
A backend server running on HTTPS with an invalid certificate will not be accepted by default. If you want to, you need to setsecure: false
."logLevel": "debug"
To help debug whether or not your proxy is working properly, you can also add the logLevel option as follows: Possible options for logLevel includedebug
,info
,warn
,error
, andsilent
(default is info)."pathRewrite": { "^/api": "" },
pathRewrite setting says that if the path matches^/api
(i.e. if it starts with /api) then rewrite that portion with the empty string (i.e. remove it from the path), so all the request tohttps://localhost:8000/api
will go tohttps://localhost:8000
"changeOrigin": true
: If you need to access a backend that is not on localhost or when you’re using some virtual proxies (such as configured with Apache2) on your backend set it to true.
proxy options
provided in this package is from underlying node-http-proxy
Proxying Support might help you to get rid off some CORS
exceptions during the development stage but There isn't much the client application can do about these exceptions The server must be configured to accept the application's requests.
I want to add CORS support to my server
NOTE: The proxy
configuration is intended to proxy calls when running the dev server via ng serve
. After you run ng build
you are responsible for the web server and its configurations.
Answered By - Vikas
0 comments:
Post a Comment
Note: Only a member of this blog may post a comment.