Generate Document Action Node

I am generating PDFs using the “Generate Document” action node. Even though the template string stays the same, the action fails often. The error messages I get are:
Access to XMLHttpRequest at '' from origin '' has been blocked by CORS policy: No 'Access-Control-Allow-Origin' header is present on the requested resource.
POST net::ERR_FAILED 502 (Bad Gateway)'

The error seems to occur when I am testing multiple times and generally does not happen the first time I generate a PDF after a while.