Обновление cokie в NuxtJS при JWT (проблема с CORS)

Всем привет.

Не могу неделю решить проблему с обновлением сокие в Nuxt.js

Вот как все происходит:

  1. Устанавливаю cookie при входе пользователя
 res.cookie('refresh_token', uui, {
            maxAge: 60 * 60* 24*2, // 60*60= 3600 - 1 час; 3600*24= 1 день; 1 день * 1 = 1 неделя
            httpOnly: true,
            secure: false,
            domain: 'localhost',
            path: '/',
            overwrite: true
        })
  1. При обновлении страницы с использованием SSR от Nuxt.js cookie не обновляется при обновлении на клиенте вызывается этот код
async nuxtServerInit(vuexContext) {
        await vuexContext.dispatch('AUTH_USER')
    }

=>

async AUTH_USER(context) {

        try {
            res = await this.$axios.$post('/api/proba',{
               withCredentials: true,
            }).then(result =>result);
        } catch (e) {
            console.error("Ошибка " +e);
            console.error(e.stack);

        }
.
.
.
  1. На сервере получаю запрос и вот так пытаюсь установить новый cookie
.
.
.
           /* res.clearCookie('refresh_token',{path:'/api',domain:'localhost'})
                res.cookie('refresh_token', "", {
                    httpOnly: true,
                    expires: new Date(0),
                    maxAge: 0,
                    domain: 'localhost',
                    path: '/',
                    overwrite: true
                });
                res.clearCookie('refresh_token',)

*/
               res.cookie('refresh_token', uui, {
                    maxAge: 60 * 60* 24*1, // 60*60= 3600 - 1 час; 3600*24= 1 день; 1 день * 1 = 1 неделя
                    httpOnly: true,
                    secure: false,
                   //domain: 'localhost',
                   path: '/',
                    overwrite: true
                })
                jwt_token.CreateToken(refresh_token_bd.userId,uui)
            console.log('Новый токен ' +uui)
     res.json({status: true, user:obUser[0], isUser: true, token: jwt_token.JwtToken(refresh_token_bd.userId)})

Я понял, что проблема в CORS

Решение через Nuxt.JS (не помог) @nuxtjs/proxy, axios: credentials: true, proxy: true

    modules: ["@nuxtjs/axios", '@nuxtjs/redirect-module', 'cookie-universal-nuxt', '@nuxtjs/proxy'],
    server:{
        port: 3000,
        host: '0.0.0.0'
    },
    axios: {
        baseURL: "http://localhost:3000/",
        withCredentials: true,
        credentials: true,
        prefix: '/',
        proxy: true
    },
    proxy: {
        '/api': { target: 'http://localhost:3000',changeOrigin: true }
    },

Вот якобы решение, но не получается первое второе

p.s при запуске nuxt в консоле выходит введите сюда описание изображения


Ответы (0 шт):