解释proxy.config.json功能角度5 [英] explain proxy.config.json features angular 5
问题描述
"/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
感谢您的帮助
推荐答案
"/api/*": {
"target": "https://localhost:8000",
"secure": false,
"logLevel": "debug",
"pathRewrite": {
"^/api": ""
},
"changeOrigin": true
}
-
"api/*"
:
您的应用程序中对/api/
的所有请求都将转发到target": "https://localhost:8000/api
-
"secure": false,
:
在HTTPS上运行的后端服务器,带有 默认情况下,无效证书将不被接受.如果你想, 您需要设置secure: false
.
"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"
帮助调试您的代理是否
工作正常,您还可以将logLevel选项添加为
如下:logLevel的可能选项包括debug
,info
,
warn
,error
和silent
(默认为info).
"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 include debug
, info
,
warn
, error
, and silent
(default is info).
"pathRewrite": {
"^/api": "" },
pathRewrite设置指出,如果路径匹配^/api
(即,它以/api开头),则用空字符串重写该部分(即,将其从路径中删除),因此所有对https://localhost:8000/api
的请求都将转到
"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 to https://localhost:8000/api
will go to https://localhost:8000
"changeOrigin": true
:如果您需要访问不在本地主机上的后端,或者在后端上使用某些虚拟代理(例如使用Apache2配置的虚拟代理)时,请将其设置为true.
"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
来自底层 node-http-proxy
proxy options
provided in this package is from underlying node-http-proxy
代理支持可以帮助您摆脱某些 CORS
在开发阶段出现异常,但客户端应用程序无法处理这些异常.必须将服务器配置为接受应用程序的请求.
I want to add CORS support to my server
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
注意:proxy
配置用于通过ng serve
运行开发服务器时代理调用.运行ng build
后,您将负责Web服务器及其配置.
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.
这篇关于解释proxy.config.json功能角度5的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!