From 0dcd0a92ccac3e253ebcf76c981758f8789e17fb Mon Sep 17 00:00:00 2001 From: Behon Baker Date: Fri, 11 Aug 2023 09:10:30 -0500 Subject: [PATCH 1/2] chore: change default api url value When using any node version above 16, the cookie was not being persisted across browser refreshes. Changing "http://localhost:1337" -> "http://127.0.0.1:1337" fixed this issue. Refer to this issue: https://github.com/nuxt-modules/strapi/issues/229 --- docs/content/2.setup.md | 4 ++-- example/nuxt.config.ts | 6 +++--- src/module.ts | 6 +++--- 3 files changed, 8 insertions(+), 8 deletions(-) diff --git a/docs/content/2.setup.md b/docs/content/2.setup.md index be5d9b89..8173cabc 100644 --- a/docs/content/2.setup.md +++ b/docs/content/2.setup.md @@ -33,7 +33,7 @@ Defaults: ```ts { - url: process.env.STRAPI_URL || 'http://localhost:1337', + url: process.env.STRAPI_URL || 'http://127.0.0.1:1337', prefix: '/api', version: 'v4', cookie: {}, @@ -47,7 +47,7 @@ If you want to override any options on runtime, you may use [Nuxt 3 runtime-conf runtimeConfig: { public: { strapi: { - url: 'http://localhost:1337' // can be overridden by NUXT_PUBLIC_STRAPI_URL environment variable + url: 'http://127.0.0.1:1337' // can be overridden by NUXT_PUBLIC_STRAPI_URL environment variable } } }, diff --git a/example/nuxt.config.ts b/example/nuxt.config.ts index 0019a4be..af33b945 100644 --- a/example/nuxt.config.ts +++ b/example/nuxt.config.ts @@ -6,14 +6,14 @@ export default defineNuxtConfig({ ], // example of separate client/server URLs // runtimeConfig: { - // strapi: { url: 'http://localhost:1337' }, + // strapi: { url: 'http://127.0.0.1:1337' }, // public: { - // strapi: { url: 'http://localhost:1337' } + // strapi: { url: 'http://127.0.0.1:1337' } // } // }, strapi: { version: 'v3', - url: 'http://localhost:1337' + url: 'http://127.0.0.1:1337' // To enable the devtools, read https://strapi.nuxtjs.org/devtools // devtools: true }, diff --git a/src/module.ts b/src/module.ts index 94c7de24..119e3bd3 100644 --- a/src/module.ts +++ b/src/module.ts @@ -12,7 +12,7 @@ export interface ModuleOptions { /** * Strapi API URL * @default process.env.STRAPI_URL - * @example 'http://localhost:1337' + * @example 'http://127.0.0.1:1337' * @type string */ url?: string @@ -74,7 +74,7 @@ export default defineNuxtModule({ } }, defaults: { - url: process.env.STRAPI_URL || 'http://localhost:1337', + url: process.env.STRAPI_URL || 'http://127.0.0.1:1337', prefix: '/api', version: 'v4', cookie: {}, @@ -82,7 +82,7 @@ export default defineNuxtModule({ cookieName: 'strapi_jwt', devtools: false }, - setup (options, nuxt) { + setup(options, nuxt) { // Default runtimeConfig nuxt.options.runtimeConfig.public.strapi = defu(nuxt.options.runtimeConfig.public.strapi, options) nuxt.options.runtimeConfig.strapi = defu(nuxt.options.runtimeConfig.strapi, options) From 1baaf7b24ccfdf0eceba69de248753cccda3a737 Mon Sep 17 00:00:00 2001 From: Benjamin Canac Date: Fri, 8 Sep 2023 14:59:46 +0200 Subject: [PATCH 2/2] Update src/module.ts --- src/module.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/module.ts b/src/module.ts index 119e3bd3..25bf3b9e 100644 --- a/src/module.ts +++ b/src/module.ts @@ -82,7 +82,7 @@ export default defineNuxtModule({ cookieName: 'strapi_jwt', devtools: false }, - setup(options, nuxt) { + setup (options, nuxt) { // Default runtimeConfig nuxt.options.runtimeConfig.public.strapi = defu(nuxt.options.runtimeConfig.public.strapi, options) nuxt.options.runtimeConfig.strapi = defu(nuxt.options.runtimeConfig.strapi, options)