'Logs on server side for nuxt ssr app not appear
Hey I am trying to convert my cache to using Redis.
I created module that get my secret from AWS and update
store.host and store.auth_pass.
I am using ECS to run my servers, after commit my changes to the server every request to the domain is stuck until 504 appear.
I don't know which part of the process is stuck all my logs on server side isn't appear in my cloud watch and when I try to debug the server with vs, they only appear when I run though the terminal.
my module init-redis
// Create a Secrets Manager client
const client = new AWS.SecretsManager({
region: region });
// In this sample we only handle the specific exceptions for the 'GetSecretValue' API.
// See https://docs.aws.amazon.com/secretsmanager/latest/apireference/API_GetSecretValue.html
// We rethrow the exception by default.
try {
const data = await client.getSecretValue({ SecretId: secretName }).promise();
if ("SecretString" in data) {
secret = data.SecretString;
secret = JSON.parse(secret);
this.options.cache.store.auth_pass = secret.password;
this.options.cache.store.host = secret.host;
}
console.log(`${data}`);
} catch (err) {
console.error(err);
}
my nuxt config modules part:
modules: [
"@nuxtjs/style-resources",
"@nuxtjs/svg",
"nuxt-i18n",
"@nuxtjs/firebase",
"@nuxtjs/redirect-module",
"@nuxtjs/sentry",
"~/modules/init-redis",
"nuxt-ssr-cache"
],
cache: {
// if you're serving multiple host names (with differing
// results) from the same server, set this option to true.
// (cache keys will be prefixed by your host name)
// if your server is behind a reverse-proxy, please use
// express or whatever else that uses 'X-Forwarded-Host'
// header field to provide req.hostname (actual host name)
useHostPrefix: false,
pages: ["/"],
key(route, context) {
return route;
},
store: {
type: "redis",
host: "localhost",
auth_pass: "XXXXX",
// maximum number of pages to store in memory
// if limit is reached, least recently used page
// is removed.
max: 1000,
// number of seconds to store this page in cache
ttl: 15,
configure: [
["maxmemory", "500mb"],
["maxmemory-policy", "allkeys-lru"]
]
}
},
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|
