After replication of data into production my public API endpoints start returning the following response:
{"data":null,"error":{"status":401,"name":"UnauthorizedError","message":"Missing or invalid credentials","details":{}}}
My Strapi implementation uses two databases - one for the administration and another for serving the live content. This allows our content managers to create content safely and preview it in a staging environment and when they’re happy with they can promote all content from the staging db into the production db - under the hood this is running pgsync which replicates one PostreSQL DB to another.
This setup and approach may be somewhat unusual but it used to work perfectly in V3 but now I’ve switched to V4 it’s causing problems. As soon as the replication completes all of my API GETs start throwing 401s. If I restart the pods everything works correctly again.
Can any advise what’s causing Strapi to throw these errors once the DB replication has occurred?
This thread may also have some information of use to anyone that’s landed over here. So far adding the pool information to my database config file as described there seems to have addressed the 401 issues I was having.
i had the same issue. this thread helped me narrowing down the issue to database connection pooling. the strapi docs are quite clear on this:
When using Docker, change the pool min value to 0 as Docker will kill any idle connections, making it impossible to keep any open connections to the database