一个关于nuxt同时使用ssr和csr的时候api服务器的跨域如何配置-灵析社区

花影流年

前端项目在服务器a,nuxt2写的,首页使用了ssr,其它页面csr,服务器配置 ``` nginx location / { proxy_pass http://localhost:3000; } ``` 后端api在服务器b,使用laravel开发,其中加入了对服务器a开启的跨域中间件。 现在发现,访问项目时,首页没有渲染,F5刷新也没有,其他页面可以渲染,从其它页面切到首页时首页可以渲染,求解。

阅读量:179

点赞量:1

问AI
1.在 API 服务器上添加 Nuxt.js 服务器的 IP 地址到白名单上,允许它发请求 2.配置 // nuxt.config.js export default { modules: [ '@nuxtjs/axios', '@nuxtjs/proxy' ], axios: { proxy: true // Can be also an object with default options }, proxy: { '/api/': 'http://your_api_server_internal_ip:port', } }