Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

配置正式环境 url #44

Closed
encorehe opened this issue Jan 20, 2017 · 6 comments
Closed

配置正式环境 url #44

encorehe opened this issue Jan 20, 2017 · 6 comments

Comments

@encorehe
Copy link

你好 我如何配置正式环境的 url 参数呢? 是注释掉 src/utils/index.js 里面的 require('./mock.js'),然后写死放到请求接口里面吗?类似这样 return request('192.168.1.123:8080/api/login', {
method: 'post',
data: params
}) 还是有地方可以配置啊,怎么配置呢?

谢谢!

@mtboom
Copy link

mtboom commented Jan 20, 2017

我注释掉了mock但是还是发不出proxy的请求,请问我应该再改哪些地方才能在本地使用proxy

@zuiidea
Copy link
Owner

zuiidea commented Jan 21, 2017

@encorehe,没有其他地方了,不过你可以在utils/config.js里添加一个字段,引入就可以了

@zuiidea
Copy link
Owner

zuiidea commented Jan 21, 2017

@mtboom,如果要使用可以本地proxy,

  • 使用npm run start命令
  • 访问localhost:8989
  • 注释掉 src/utils/index.js 里的 mock

@mtboom
Copy link

mtboom commented Feb 3, 2017

@zuiidea 问题已经解决
使用npm run start命令
访问localhost:8989
注释掉 src/utils/index.js 里的 mock
使用 fetch 发送请求

@wuyongdec
Copy link

@mtboom
本地proxy怎么配置呢?
是不是类似这样:
"proxy": { "/api": { "target": "http://jsonplaceholder.typicode.com/", "changeOrigin": true, "pathRewrite": { "^/api" : "" } } }

@102010cncger
Copy link

102010cncger commented Mar 5, 2017

我用springboot的zuul做的代理

配置如下,坑了我好久的是必须配置/base/而不是/base,希望能给大家帮助

package.json中

"scripts": {
"start": "dora --plugins "proxy,webpack?publicPath=/base/,webpack-hmr,browser-history?index=/src/index.html"",
"dev": "dora --plugins "webpack?publicPath=/base/,webpack-hmr,browser-history?index=/src/index.html"",
"lint": "eslint --fix --ext .js,.jsx src/components/layout",
"build": "atool-build"
},

zuul配置如下

#eit反向代理到8000端口,多个用,分隔
zuul.routes.base.path=/base/**
zuul.routes.base.url=http://127.0.0.1:8000
zuul.routes.base.stripPrefix=false
#eit.ribbon.listOfServers=127.0.0.1:8080

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

5 participants