Closed
Description
Environment
- Operating System: Darwin
- Node Version: v18.17.1
- Nuxt Version: 3.7.4
- CLI Version: 3.9.0
- Nitro Version: 2.6.3
- Package Manager: npm@9.6.7
- Builder: -
- User Config: devtools, build, alias, ssr, runtimeConfig, nitro, vite, modules, auth, i18n, experimental, css, pinia, app
- Runtime Modules: @pinia/nuxt@0.4.11, @pinia-plugin-persistedstate/nuxt@1.1.2, @nuxtjs/i18n@8.0.0-rc.5, @sidebase/nuxt-auth@0.6.0-rc.0
- Build Modules: -
client : npm run generate > npx serve [output static directory] -l 3001
node server : npm run build(port 3000) > node index.mjs
Reproduction
- Call signIn on Login Page.
const { signIn, status } = useAuth();
setUser(<resLoginType>returnData.value.rs);
// await authLogin();
const wrapBody = {
username: loginId.value,
password: passwd.value,
};
await signIn(wrapBody, { redirect: false });
navigateTo('/main', { replace: true });
- signin is authorize and then move main page. (Screenshots : Chrome Inspector Application > Cookie and check useAuth status value)


- After refreshing the browser, useAuth status value is lost and move the login.

Describe the bug
- Authentication passed on the login page.
- Refreshed the main page.
- Authentication status is lost and moved to the login page.
I guess this is probably a problem that occurs when pre-rendering is performed on the client-driven server side.
Is there a solution to this?
Additional context
"nuxt.config.ts" part the below.
import { resolve } from 'node:path';
// https://nuxt.com/docs/api/configuration/nuxt-config
export default defineNuxtConfig({
devtools: { enabled: true },
build: {
transpile: ['vuetify', 'jsonwebtoken'],
},
alias: {
'./runtimeConfig': './runtimeConfig.browser',
cookie: resolve(__dirname, 'node_modules/cookie'),
},
ssr: true,
runtimeConfig: {
public: {
baseApiUrl: process.env.BASE_API_URL,
midAwsUrl: process.env.MIDDLEWARE_LAMBDA_URL,
mode: process.env.ENV_MODE,
},
},
nitro: {
preset: 'node-server', //'aws-lambda',
storage: { '.data:auth': { driver: 'fs', base: './.data/auth' } },
routeRules: {
'/': { ssr: true, prerender: true },
},
},
vite: {
envDir: process.cwd(),
define: {
'process.env.DEBUG': false,
'window.global': {},
},
css: {
preprocessorOptions: {
scss: {
additionalData: '@import "@/assets/main.scss"; ',
},
},
},
},
modules: [
'@pinia/nuxt',
'@pinia-plugin-persistedstate/nuxt',
'@nuxtjs/i18n',
'@sidebase/nuxt-auth',
],
auth: {
provider: {
type: 'local',
token: {
signInResponseTokenPointer: '/token/accessToken',
maxAgeInSeconds: 18000,
// sameSiteAttribute: 'lax',
},
},
baseURL: 'http://localhost:3000/api/auth',
globalAppMiddleware: {
isEnabled: true,
},
},
i18n: {
strategy: 'no_prefix',
locales: [
{
code: 'vi',
name: 'Vietnamese',
file: 'vi-VN.ts',
},
{
code: 'en',
name: 'English',
file: 'en-US.ts',
},
{
code: 'ko',
name: 'Korean',
file: 'ko-KR.ts',
},
],
experimental: {
jsTsFormatResource: true,
},
lazy: true,
langDir: 'lang',
defaultLocale: 'en',
},
experimental: {
payloadExtraction: false,
},
css: ['vuetify/styles', '@/assets/dev.scss'],
pinia: {
autoImports: [
// `defineStore`를 자동으로 임포트함.
'defineStore', // import { defineStore } from 'pinia'
['defineStore', 'definePiniaStore'], // import { defineStore as definePiniaStore } from 'pinia'
],
},
app: {
head: {
title: 'D-Sales Store',
// titleTemplate: 'input title template',
link: [
{ rel: 'stylesheet', href: '' },
{ rel: 'preconnect', href: '' },
{ rel: 'icon', type: 'image/x-icon', href: '/favicon.ico' },
// font - NotoSans 추가
{
rel: 'stylesheet',
type: 'text/css',
href: 'https://fonts.googleapis.com/css?family=Noto+Sans+KR:400,500,700',
},
],
},
},
});
Logs
No response