如何在 angularcli 项目的 proxy.config.json 文件中设置代理标头 [英] How set proxy headers in proxy.config.json file for angularcli project

查看:26
本文介绍了如何在 angularcli 项目的 proxy.config.json 文件中设置代理标头的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试为 angularcli 设置代理标头.这是我目前在 proxy.config.json 文件中的内容:

I'm trying to set proxy headers for angularcli. Here's what I have so far in my proxy.config.json file:

"/api": {
    "target": "https://applications.str.coni.com/api",
    "secure": false,
    "logLevel": "debug"

但到目前为止我还没有任何运气,也许我遗漏了一些东西(可能在另一个文件中).任何建议将不胜感激.

But I haven't had any luck so far, perhaps I'm missing something (probably in another file). Any suggestions would be much appreciated.

推荐答案

Angular-cli 使用 http-proxy-middleware https://github.com/chimurai/http-proxy-middleware

Angular-cli uses http-proxy-middleware https://github.com/chimurai/http-proxy-middleware

有一个名为 headers 的选项可供您使用:https://github.com/chimurai/http-proxy-middleware#http-proxy-option

there is an option called headers that you can use: https://github.com/chimurai/http-proxy-middleware#http-proxy-option

示例:

"/api":
  {
    "target": "https://applications.str.coni.com/api",
    "secure": false,
    "logLevel": "debug",
    "headers": {"host":"www.example.org"}
  }

这篇关于如何在 angularcli 项目的 proxy.config.json 文件中设置代理标头的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆