Gary
Gary
NNuxt
Created by Gary on 5/29/2024 in #❓・help
Simple Lambda Cookie Question
tldr: Do cookies work on initial page load on AWS Lambda? Hey folks - building something for aws-lambda and everything is up and running except the useCookie method on initial load: I'm reading it in some routeMiddleware and looks something like this:
export default defineNuxtRouteMiddleware((to) => {
if (to.path !== '/pin-code') {
const accessToDocs = useCookie('access-to-docs')

if (!accessToDocs.value || accessToDocs.value.toString() !== '123456')
return navigateTo(`/pin-code`, { redirectCode: 401 })
}
})
export default defineNuxtRouteMiddleware((to) => {
if (to.path !== '/pin-code') {
const accessToDocs = useCookie('access-to-docs')

if (!accessToDocs.value || accessToDocs.value.toString() !== '123456')
return navigateTo(`/pin-code`, { redirectCode: 401 })
}
})
So, simple test to see if they are on any route other than pin-code and if they are I read the cookie. If the cookie isnt there or it doesn't equal to my super secure password I redirect them to the pin-code page. This works totally fine locally. On Lambda it works on any subsequent page as you click around and router is used. However, initial page load doesn't seem to be able to read the cookie. What am I missing?
3 replies
NNuxt
Created by Gary on 4/24/2024 in #❓・help
Docus color override
Anyone happen to know how to override the colors in the Docus theme for Nuxt content? I see they are using Pinceau but I'm not familiar with that project - not sure how to override the tokens file.
1 replies
NNuxt
Created by Gary on 5/31/2023 in #❓・help
Nitro routeRules shouldInvalidateCache
Not sure I understand how or why but from Nuxt nuxt.config.ts why do the shouldInvalidateCache and shouldBypassCache functions not work? If I do the following:
nitro: {
routeRules: {
'/**': {
cache: {
swr: true,
maxAge: 60 * 60,
shouldInvalidateCache: () => true,
shouldBypassCache: () => true,
},
},
},
},
nitro: {
routeRules: {
'/**': {
cache: {
swr: true,
maxAge: 60 * 60,
shouldInvalidateCache: () => true,
shouldBypassCache: () => true,
},
},
},
},
<script setup lang="ts">
const time = new Date().getTime()
</script>

<template>
{{ time }}
</template>
<script setup lang="ts">
const time = new Date().getTime()
</script>

<template>
{{ time }}
</template>
Time never updates until the maxAge expires. I would imagine that cache would be invalidated every time the page loaded.
1 replies
NNuxt
Created by Gary on 5/19/2023 in #❓・help
defineNuxtPlugin is not defined
Why would a module I write that uses "addPlugin" cause this issue?
defineNuxtPlugin is not defined
defineNuxtPlugin is not defined
It works fine in the development mode in the playground but bombs when I implement it as a package.
15 replies
NNuxt
Created by Gary on 4/24/2023 in #❓・help
Invalidating and bypassing routeRules cache
Hey folks - any chance anyone has setup a routeRule in the nitro config that can be invalidated and/or bypassed? I can do it in the server with cachedEventHandler but not in the routeRules. Any help here would be sooooo appreciated
1 replies