【发布时间】:2015-12-24 18:52:07
【问题描述】:
我可能做错了什么,但我无法强制 grunt-contrib-proxy 进行简单的重定向。
在我的 gruntfile.coffee (yup coffeescript) 我有以下服务器配置:
connect:
devserver:
options:
port: 9001
base: "./"
proxies: [{
context: "/",
host: 'dev.staging.com'
changeOrigin: true
}]
我还补充说: grunt.loadNpmTasks "grunt-connect-proxy" 并用“configureProxies:devserver”更新了我的任务
我相信这应该将任何呼叫重定向到 dev.staging.com, 所以当我输入 http://localhost:9001 时,我应该被重定向到 url http://dev.staging.com
但是,代理似乎根本不起作用。我尝试了多种配置(即使重写),但仍然没有运气。
我可能做错了什么,但我不知道是什么...
Grunt 正确编译并运行任务。
【问题讨论】:
-
现在当我更改上下文时:“/api”每当我启动我的应用程序时,我都会得到:“Cannot GET /”。我想我会选择其他代理。没有任何其他简单的工具可以在没有所有这些不必要的配置的情况下进行重定向吗?
标签: javascript proxy coffeescript gruntjs grunt-contrib-connect