yahms23
yahms23

Reputation: 336

404 Error with accessing media in Strapi sometime after uploading

Some context:

I have Strapi deployed on Heroku successfully with a MongoDB backend, and can add/edit entries. My issue comes when I upload an image using the media library plug in. I'm able to upload an image, and have my frontend access it initially, displaying it etc. after sometime, like the next day or in an hour or so, the history of the file is present, as can be seen with this endpoint:

https://blog-back-end-green.herokuapp.com/upload/files/

However, the url endpoint to access the media doesn't work as it used to, and I get a 404 error when I follow it to the endpoint. e.g.

https://blog-back-end-green.herokuapp.com/uploads/avatarperson_32889bfac5.png

New to Strapi so any help/guidance appreciated

Upvotes: 0

Views: 2203

Answers (2)

softcode
softcode

Reputation: 4648

The docs address your question directly:

Like with project updates on Heroku, the file system doesn't support local uploading of files as they will be wiped when Heroku "Cycles" the dyno. This type of file system is called ephemeral, which means the file system only lasts until the dyno is restarted (with Heroku this happens any time you redeploy or during their regular restart which can happen every few hours or every day).

Due to Heroku's filesystem you will need to use an upload provider such as AWS S3, Cloudinary, or Rackspace. You can view the documentation for installing providers here and you can see a list of providers from both Strapi and the community on npmjs.com.

Upvotes: 3

Cem Kaan
Cem Kaan

Reputation: 2226

When your app runs, it consumes dyno hours of HEROKU

When your app idles (automatically, after 30 minutes of inactivity), as long as you have dyno hours, your app will be live and publicly accessible.


Generally, Authentication failures return a 401 (unauthorized) error but in some platforms, 404 error can also return.

Check Your second request does have the correct Authorization header

Check out role-permissions

Upvotes: 0

Related Questions