How to implement static page generation if my API server is not available at the Next build stage?
Unanswered
Ojos Azules posted this in #help-forum
Ojos AzulesOP
My infrastructure is configured in a such way that my frontend and backend are building in parallel. During the Next build stage my API server does not work - it cannot respond to requests with data, so Next caches the "error" response, as a result my website displays stubs instead of data. The only way I found to update the "error cache" is to make an additional request to revalidate data. But this is a rather fragile workaround to my taste, because every time after the Next start I have to make additional requests for revalidation. Is there any better way to set up this process? I think these are quite common conditions when we cannot guarantee that at the Next build stage we have a working API server.
1 Reply
Africanized honey bee
I'm not sure that it would be possible to implement static page generation as you intend without being able to query your api for the necessary data. It needs this information at build time. I think a better strategy for your situation might be to work on the building pipeline itself and switch to a more sequential pipeline such that the api is built and deployed in a first stage, followed by the next.js app afterwards.