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

157. 线上http 协议更新为https,本地http-proxy踩坑 #157

Open
ly525 opened this issue Sep 25, 2018 · 0 comments
Open

157. 线上http 协议更新为https,本地http-proxy踩坑 #157

ly525 opened this issue Sep 25, 2018 · 0 comments

Comments

@ly525
Copy link
Owner

ly525 commented Sep 25, 2018

npm http-proxy 启用 https 的方式:

问题描述:

  1. Local http:127.0.0.1:8088 -> Server https://www.xxx.com/api/v1
  2. 后端环境:Django 1.11
  3. 前端配置环境:
package.json dev 配置:
"dev": "webpack-dev-server --inline --progress  --config build/webpack.dev.conf.js",
proxyTable: {
      '/api/v1': {
        // target: 'https://www.xxx.com/',
        changeOrigin: true,
        secure: false,
      },
},
  1. Bug:
data: {detail: "CSRF Failed: Referer checking failed - 
Referer is insecure while host is secure."}
  1. 解决:
package.json dev 配置: 添加https,浏览器访问:https:127.0.0.1:8088 即可
"dev": "webpack-dev-server --inline --https --progress  --config build/webpack.dev.conf.js",
  1. How to run Vue.js dev serve with https?
  2. https://stackoverflow.com/questions/18642828/origin-http-localhost3000-is-not-allowed-by-access-control-allow-origin
  3. https://stackoverflow.com/questions/45807049/how-to-run-vue-js-dev-serve-with-https 中包含了 vue-cli3的解决方案。

附送另外一个Bug:

Bug:

detail: "CSRF Failed: Referer checking failed -
 https://127.0.0.1:8088/ does not match any trusted origins."

需要后端修改验证规则(Django):

CSRF_TRUSTED_ORIGINS = [
    # may have to include host AND port
    '127.0.0.1',
    '127.0.0.1:8088',
]
@ly525 ly525 changed the title 157. test for new blog 157. 线上http 协议更新为https,本地http-proxy踩坑 Sep 28, 2018
@ly525 ly525 added the HTTP label Dec 7, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

1 participant