Nginx proxy_pass 不适用于 nuxtServerInit

时间:2021-02-24 20:36:08

标签: nginx nuxt.js nginx-reverse-proxy

我使用 nginx 代理设置了 nuxt 项目。当我尝试在第一次加载(服务器端)期间刷新身份验证令牌时,除了 nuxtServerInit 之外,一切正常

商店中的nuxtServerInit 不起作用...

async nuxtServerInit( store, { req } ) {
  const { data } = await this.$axios.post('api/user/refresh', { token: token } );
}

在项目中的任何地方

async button(){
      try {
        const { data } = await this.$axios.post('api/user/refresh', { token: sometoken } );
      } catch (error) {
        console.log(error);
      }
    }

在 nginx 配置中

location /api/ {
   
    proxy_pass http://backend:4000/;
  }

提前致谢

0 个答案:

没有答案
相关问题