xswitch 可以在运行时修改html代码

google 浏览器安装xswitch

image.png
image.png
image.png
image.png

image.png

  1. {
  2. "proxy": [
  3. // [
  4. // "http://xxx.xxx.xxx/jxt/js/app.(.*).js",
  5. // "http://localhost:8000/jxt/js/app.js"
  6. // ],
  7. ]
  8. }

结合express做代理

  1. var express = require('express')
  2. var app = express()
  3. var path = require('path')
  4. app.set('port', process.env.PORT || 3000)
  5. app.all('*', function (req, res, next) {
  6. console.log('res')
  7. res.header('Access-Control-Allow-Credentials', 'true')
  8. // href 设置指定的白名单域名 例如 "https://www.baidu.com"
  9. // 记得修改 href
  10. const href = '*'
  11. res.header('Access-Control-Allow-Origin', href)
  12. res.header('Access-Control-Allow-Headers', 'X-Requested-With')
  13. res.header('Access-Control-Allow-Methods', 'PUT,POST,GET,DELETE,OPTIONS')
  14. res.header('X-Powered-By', '3.2.1')
  15. res.header('Content-Type', 'application/json;charset=utf-8')
  16. next()
  17. })
  18. console.log(path.join(__dirname, '../static'))
  19. app.use(express.static(path.join(__dirname, '../static'))) // 设置静态文件目录,外网可直接访问。
  20. app.listen(app.get('port'), function () {
  21. console.log(`Express started on http://localhost:${app.get('port')}; press Ctrl + c to terminate.`)
  22. })