ProxyTable
をテンプレートにして作成
[
トップ
] [
新規
|
一覧
|
検索
|
最終更新
|
ヘルプ
|
ログイン
]
開始行:
[[Vue]]
&color(red){※前提条件:本文基于 Vue 2.0 创作};
#contents
* 概要 [#ueb5c50a]
在项目开发过程中,一般都是在同一域名下进行接口联调,且不...
#codeprettify{{
dev: {
// 静态资源文件夹
assetsSubDirectory: 'static',
// 发布路径
assetsPublicPath: '/',
// 代理配置表,在这里可以配置特定的请求代理到对应的API...
// 例如将'localhost:8080/api/xxx'代理到'www.example.com...
// 使用方法:https://vuejs-templates.github.io/webpack/...
proxyTable: {
'/api': {
target: 'http://xxxxxx.com', // 接口的域名
// secure: false, // 如果是https接口,需要配置这个...
changeOrigin: true, // 如果接口跨域,需要进行这个参...
pathRewrite: {
'^/api': ''
}
}
},
// 本地访问 http://localhost:8080
host: 'localhost', // can be overwritten by process.env.H...
}}
接口地址原本是 /save/index,但是为了匹配代理地址,在前面...
&color(red){注意:};
-"/api" 为匹配项,target 为被请求的地址,因为在 ajax 的 u...
--而原本的接口是没有这个前缀的,所以需要通过 pathRewrite ...
--如果本身的接口地址就有"/api" 这种通用前缀,就可以把 pat...
#codeprettify{{
'/api': {
target: 'http://192.168.0.73:8889/', //请求后台接口
// secure: false, // 如果是https接口,需要配置这...
changeOrigin: true, // 如果接口跨域,需要进行这个...
// pathRewrite: {
// '^/api': '', // 重写请求
// },
},
}}
所以按照上面的ProxyTable的写法,实际服务的配置路径里面不...
* Tips [#y33986a7]
如果api的路径里面不是api开头的,比如,下面的something后面...
http://wwww.exam.com/something/api/login
#codeprettify{{
'/api': {
target: 'http://wwww.exam.com', //域名
changeOrigin: true, // 如果接口跨域,需要进行这个...
pathRewrite: {
'^/api': '/something/api', // 重写请求
},
},
}}
#hr();
コメント:
#comment_kcaptcha
終了行:
[[Vue]]
&color(red){※前提条件:本文基于 Vue 2.0 创作};
#contents
* 概要 [#ueb5c50a]
在项目开发过程中,一般都是在同一域名下进行接口联调,且不...
#codeprettify{{
dev: {
// 静态资源文件夹
assetsSubDirectory: 'static',
// 发布路径
assetsPublicPath: '/',
// 代理配置表,在这里可以配置特定的请求代理到对应的API...
// 例如将'localhost:8080/api/xxx'代理到'www.example.com...
// 使用方法:https://vuejs-templates.github.io/webpack/...
proxyTable: {
'/api': {
target: 'http://xxxxxx.com', // 接口的域名
// secure: false, // 如果是https接口,需要配置这个...
changeOrigin: true, // 如果接口跨域,需要进行这个参...
pathRewrite: {
'^/api': ''
}
}
},
// 本地访问 http://localhost:8080
host: 'localhost', // can be overwritten by process.env.H...
}}
接口地址原本是 /save/index,但是为了匹配代理地址,在前面...
&color(red){注意:};
-"/api" 为匹配项,target 为被请求的地址,因为在 ajax 的 u...
--而原本的接口是没有这个前缀的,所以需要通过 pathRewrite ...
--如果本身的接口地址就有"/api" 这种通用前缀,就可以把 pat...
#codeprettify{{
'/api': {
target: 'http://192.168.0.73:8889/', //请求后台接口
// secure: false, // 如果是https接口,需要配置这...
changeOrigin: true, // 如果接口跨域,需要进行这个...
// pathRewrite: {
// '^/api': '', // 重写请求
// },
},
}}
所以按照上面的ProxyTable的写法,实际服务的配置路径里面不...
* Tips [#y33986a7]
如果api的路径里面不是api开头的,比如,下面的something后面...
http://wwww.exam.com/something/api/login
#codeprettify{{
'/api': {
target: 'http://wwww.exam.com', //域名
changeOrigin: true, // 如果接口跨域,需要进行这个...
pathRewrite: {
'^/api': '/something/api', // 重写请求
},
},
}}
#hr();
コメント:
#comment_kcaptcha
ページ名: