跨域問題,通過 @nuxtjs/proxy 解決
// nuxt.config.js
modules: [
'@nuxtjs/proxy'
],
proxy: [
[
'/api/',
{
target: 'siteexample.com'
}
],
[
'/oauth2.0/',
{
target: 'siteexample.com'
}
]
]
referer 或 origin 問題,通過本地配置 host 解決
注意配 host 不包含端口號(hào)
// hosts
192.168.0.43 m.siteexample.com
nuxt 本地運(yùn)行的 host 和 port 可在 package.json 中設(shè)置更改
// package.json
{
"config": {
"nuxt": {
"host": "192.168.0.43",
"port": "8980"
}
}
}
現(xiàn)在瀏覽器打開地址為 m.siteexample.com:8980/