vue-cli 设置跨域代理,本地正常访问,线上地址报404。这是什么原因?

vue-cli中跨域代理设置:

module.exports = {

dev: {

// Paths

assetsSubDirectory: 'static',

assetsPublicPath: '/',

proxyTable: {

'/api': {

target: 'https://xxx.xxx-xxx.com',

changeOrigin: true,

pathRewrite: {

'^/api': ''

}

}

},

// Various Dev Server settings

host: ip(), // can be overwritten by process.env.HOST

port: 9999, // can be overwritten by process.env.PORT, if port is in use, a free one will be determined

autoOpenBrowser: false,

errorOverlay: true,

notifyOnErrors: true,

poll: false, // https://webpack.js.org/configuration/dev-server/#devserver-watchoptions-

// Use Eslint Loader?

// If true, your code will be linted during bundling and

// linting errors and warnings will be shown in the console.

useEslint: true,

// If true, eslint errors and warnings will also be shown in the error overlay

// in the browser.

showEslintErrorsInOverlay: false,

/**

* Source Maps

*/

// https://webpack.js.org/configuration/devtool/#development

devtool: 'eval-source-map',

// If you have problems debugging vue-files in devtools,

// set this to false - it *may* help

// https://vue-loader.vuejs.org/en/options.html#cachebusting

cacheBusting: true,

// CSS Sourcemaps off by default because relative paths are "buggy"

// with this option, according to the CSS-Loader README

// (https://github.com/webpack/css-loader#sourcemaps)

// In our experience, they generally work as expected,

// just be aware of this issue when enabling this option.

cssSourceMap: false,

},

build: {

// Template for index.html

index: path.resolve(__dirname, '../dist/index.html'),

// Paths

assetsRoot: path.resolve(__dirname, '../dist'),

assetsSubDirectory: 'static',

assetsPublicPath: './',

/**

* Source Maps

*/

productionSourceMap: true,

// https://webpack.js.org/configuration/devtool/#production

devtool: '#source-map',

// Run the build command with an extra argument to

// View the bundle analyzer report after build finishes:

// `npm run build --report`

// Set to `true` or `false` to always turn it on or off

bundleAnalyzerReport: process.env.npm_config_report

}

}

utils.js 文件中的请求地址设置:

function network (path, flag) {

if (flag) {

return `api/${path}`

}

return `api/api/${path}`

}

本地请求正常,线上请求会报404 的错误,线上报错图片:

vue加跨域代理静态文件404_vue-cli 设置跨域代理 线上地址报404相关推荐

  1. vue项目本地跨域、线上跨域、本地链接线上地址跨域、https站点使用ws协议跨域问题解决

    本地跨域---->配置vue.config.js .env.development文件 # just a flag ENV = 'development'# base api VUE_APP_B ...

  2. django 1.3下关于静态文件staticfiles的设置

    Django 1.3版本发布有些日子了,在站点被屏蔽的这段时间里学习也处于荒废状态,因此到今天才真正接触到新版下Static文件的处理设置,希望不算太晚. 更改设置涉及的文件: settings.py ...

  3. html action能跨域么,ASP.NET MVC 中设置跨域

    原标题:ASP.NET MVC 中设置跨域 来源:GetPower cnblogs.com/gdpw/p/9236661.html 程序员共读整理发布,转载请联系作者获得授权ASP.NET MVC中设 ...

  4. 如何给html文件加背景图片,怎么在文件夹中设置背景图片

    在文件夹中设置美丽的背景图片,可以让你的电脑显得与众不同,下面是学习啦小编给大家整理的一些有关在文件夹中设置背景图片的方法,希望对大家有帮助! 在文件夹中设置背景图片的方法 打开你要设置背景的文件夹, ...

  5. vue加跨域代理静态文件404_解决vue本地环境跨域请求正常,版本打包后跨域代理不起作用,请求不到数据的方法——针对vue2.0...

    问题:在本地使用了proxyTable代理可以正常跨域请求后台数据,打包上传后就无法获得后台的json文件.查看了相关资料可以用nginx进行解决.还可以使用命名环境变量,请求的时候进行判断,话不多说 ...

  6. vue加跨域代理静态文件404_解决vue-router history模式和跨域代理 部署到IIS时404的一些问题...

    先解决history模式的问题: 在网站根目录中创建web.config文件,内容如下: //通配所有连接 //因为是单页面,所以将所有连接重定向到 "/",就是指向我们项目中的首 ...

  7. Vue加element Ui 实现下载文件和进度条展示。

    <template><el-progress :percentage="percentage"></el-progress><h1> ...

  8. win运行pycharm找不到要加载的model.pkl文件是workingspace设置路径与文件路径位置不对应

    windows环境中运行pycharm提示找不到要加载的model.pkl路径,原来是pycharm中有一个workingspace设置的路径没有跟当前代码的路径位置对应所致. pycharm中左边文 ...

  9. 每天一点点之vue框架开发 - History 模式下线上路由报404错误

    vue-router 默认 hash 模式 -- 使用 URL 的 hash 来模拟一个完整的 URL,于是当 URL 改变时,页面不会重新加载. 如果不想要很丑的 hash,我们可以用路由的 his ...

最新文章

  1. python3实现zip格式压缩文件夹
  2. Docker + Intellij IDEA,提升 10 倍生产力!
  3. Android加速度传感器实现“摇一摇”,带手机振动
  4. 内存中绘图 Memdc
  5. 安装mysql-connector-python-8.0.11-py3.6遇到问题
  6. 国产毫米波雷达领域的领头羊,木牛科技将在明年量产77GHz汽车雷达
  7. 自旋锁SpinLock小案例
  8. oenwrt 进不了bios_为什么进不bios_进不了bios怎么解决?
  9. Could not connect to Redis at IP No route to host
  10. python期末复习卷_【期末复习卷A】六年级科学上册期末复习试题
  11. Introduction to Latent Dirichlet Allocation
  12. Microsoft Forms产品分析报告
  13. jmeter接口性能测试实例
  14. 解决Quartus.18.0版本 usb bluster插上蓝屏问题
  15. Spotlight搜索技巧
  16. 查看DBUS接口的工具: D-Feet
  17. 校招,面试,学习路线,这个编程学习网站,我爱了
  18. scons 手册_SCons用户手册 | 学步园
  19. Anaconda 安装与 使用
  20. express使用中base64编码和解码

热门文章

  1. leaf 叶子(张量)
  2. 再会迪杰斯特拉(Dijkstra)
  3. Leetcode--55. 跳跃游戏
  4. mysql数据库基础 博客园_MySQL数据库基础
  5. hog函数的用法 python_Python常见内置函数用法(三)
  6. python打乱顺序的洗牌函数
  7. 协方差理解,PCA以及奇异值分解(SVD)
  8. Android之自定义控件入门
  9. python实现统计你一共写了多少行代码
  10. 实现超级玛丽上下左右运动