Dynamically putting image into /public during runtime causes error
Answered
American Shorthair posted this in #help-forum
American ShorthairOP
If your next.js application dynamically adds images to /public during runtime, the image will exist in the correct spot, but when loaded produces an error
restarting the application fixes it. And it only happens when running in production, but in dev it works how you would expect.
Bug....? So then how would you dynamically serve images that may not exist when starting the server.....?
⨯ The requested resource isn't a valid image for /images/player_heads/e281289d-4eff-4851-9cb5-8fc3388dee7e.png received text/html; charset=utf-8restarting the application fixes it. And it only happens when running in production, but in dev it works how you would expect.
Bug....? So then how would you dynamically serve images that may not exist when starting the server.....?
Answered by American Shorthair
2 Replies
Asian black bear
Consider /public as read-only. Don’t write into it. For dynamic blobs use S3 or R2.
American ShorthairOP
Answer