We have a Netlify function that we use for programmatically updating specific files that are deployed. We do this for previews, as it’s faster than rebuilding the entire site.
For updating JSON files, this has worked really well.
Now we’re trying to update HTML files, and we’re stuck.
We generate our HTML files via Pug templates (which is rendered with data, which we fetch during build).
It’s close to working really well, but when viewing the deploy preview created we simply see (where the ID is different each time, I think):
Not found - Request ID: c746cac3-5728-4f6d-8db5-144310e23443-11884272
There bug seems to be somewhere in the upload (PUTing the updated HTML files) to Neltify via the API.
We can see that the deploy instance gets successfully created but looking at the Netlify UI:
So we’re successfully creating the deploy instance, but the files aren’t getting there.
The response for each PUT (to /deploys/[deploy-id]/files/[file-name]
) suggests a problem:
{
"size": 0,
"timeout": 0
}
The strange thing is that all of these responses return 200
s (suggesting all is good, even thought it’s not).
Here’s the body of our PUT (for passing the updated data):
method: 'PUT',
body: Buffer.from('string-of-HTML', 'utf8'), // Where `string-of-HTML` is the actual string of HTML. Have also tried not passing an encoding type, and also padding `base64` as the encoding type.
headers: headers('application/octet-stream'),
Any thoughts/suggestions/ideas?