After some time of inactivity, api calls return a 401, when reloading (once or twice) it works.
I call the api using useStrapi4()
and find()
. The Public
role has permission to find
and findOne
of the collection type I am querying.
The request:
...
mounted() {
this.$strapi.find("home").then(({data}) => {
this.page = data;
});
},
...
The response:
{
"data": null,
"error": {
"status": 401,
"name": "UnauthorizedError",
"message": "Missing or invalid credentials",
"details": {}
}
}
I have a hunch that it may have something to do the the JWT token, but I don't know how to debug it.
By default, Strapi kills the server when there are fewer than two connections for some time. So setting pool
to 0
makes sure that the server is up even if there are zero connections.
This worked for me:
// config/database.js
module.exports = ({ env }) => ({
connection: {
// other config …
pool: {
min: 0, // ← this line is important
}
},
});