Media Get Access 404 Error

default discord avatar
muperdev
8 months ago
196

Hi, everytime I try to gett media from the frontend I faced some 404 error, meanwhile I have access read true in both my media and collection config and auth false in both but I still facing this, I need response very fast because it's in production

  • discord user avatar
    jesschow
    Payload Team
    8 months ago

    Can you send the exact error in? Have you configured CORS already?

  • default discord avatar
    jessesivonen
    8 months ago

    If it helps, 404 usually indicates that the file cannot be found. Can you find it in your filesystem / storage?

  • default discord avatar
    muperdev
    8 months ago


    there is no exact error actually, and yes Im using cors accross the project



    yeah, you're right but that file with this url exist in DB but it doesn't shows anything at all when i put the URL externally



    @jesschow





    I get this everytime



    I understand now that all of my files start to disappearing after a few minutes and is not showing on the cms even



    I can share the config file for collection



    or if you give me email I can give access to source code

    image.png
    image.png
  • default discord avatar
    jessesivonen
    8 months ago

    It sounds like you haven't configured persistent storage for your files on the server.



    https://payloadcms.com/docs/production/deployment#file-storage


    What kind of server / hosting service are you using?

  • default discord avatar
    muperdev
    8 months ago

    I'm using payload cloud for the cms and vercel for frontend



    I'm reading it now



    what if I don't want to use any kind of EC2 or digital ocean ?



    @jessesivonen if you don't mind can you help me to configure S3 ?

  • default discord avatar
    jessesivonen
    8 months ago

    It isn't automatically configured in Payload Cloud? I haven't used it so I don't know.



    Sorry, I cannot help now. It's night here and I'll try to get some sleep.

  • default discord avatar
    muperdev
    8 months ago

    I find it, thank you for mentioning but



    have a good night



    Im trying to solve the problem with s3



    no should do it manually



    @jesschow I configured my payload config file with s3, is there anything needed to be config?

  • discord user avatar
    jesschow
    Payload Team
    8 months ago

    check out the

    plugin-cloud-storage

    and the instructions here for s3

    https://github.com/payloadcms/plugin-cloud-storage#s3-adapter
  • default discord avatar
    muperdev
    8 months ago


    this error happens when I installed the plugin as the documentation



    @jesschow

    image.png
  • discord user avatar
    jesschow
    Payload Team
    8 months ago

    Hi @muperdev apologies I sent the wrong link yesterday, this should be the plugin you need:

    https://github.com/payloadcms/plugin-cloud

    and I'll be available today to help you figure this out

  • default discord avatar
    muperdev
    8 months ago

    so what about the s3?



    I would not configure that?

  • discord user avatar
    jesschow
    Payload Team
    8 months ago

    since you are using Payload Cloud, this will be automatically configured for you - you should be able to see your file storage details by going to

    https://payloadcms.com/cloud/YOUR-TEAMNAME/PROJECT-NAME/file-storage

    (replace teamname and project name with your own)

  • default discord avatar
    muperdev
    8 months ago

    ok I'll check it

  • discord user avatar
    denolfe
    Payload Team
    8 months ago

    @muperdev I can help here. To add to what Jess said, if you pull in that plugin, the S3 storage provided by Payload Cloud will automatically be configured. Were you able to give that a shot? Proper usage of the plugin can be seen here:

    https://github.com/payloadcms/template-blank/blob/main/src/payload.config.ts#L26
  • default discord avatar
    muperdev
    8 months ago

    well if it is automatically here so why my pictures dissapear after a while





    this is my file storage in cloud



    @denolfe @jesschow I need your help ASAP





    look I miss every file after few minutes

    image.png
    image.png
  • default discord avatar
    notchr
    8 months ago

    But they did display prior?

  • default discord avatar
    muperdev
    8 months ago

    yes they did



    multiple times



    even when they are displaying after I reload the url they disapear

  • default discord avatar
    notchr
    8 months ago

    So to confirm, they display when you enter the absolute url to the image



    but then on reload they dissapear?



    Or they display in the admin panel, and then display after refresh of the admin panel?



    Maybe we can figure out the origin by this information

  • default discord avatar
    muperdev
    8 months ago

    yes, and after a while they will not display even when I enter the URL

  • default discord avatar
    notchr
    8 months ago

    So you have access to the server hosting the content?



    like ssh access?

  • default discord avatar
    muperdev
    8 months ago

    I didn't try but it's S3



    here

  • default discord avatar
    notchr
    8 months ago

    If you enable logging on your S3 bucket, it can show you why a file was deleted



    Perhaps that can get us closer as well



    If there is an expiry policy enabled for uploads, that will be evident in the logs as well

  • default discord avatar
    muperdev
    8 months ago

    let me find out how to login there



    stay with me but 😂

  • default discord avatar
    notchr
    8 months ago

    the Payload team will likely have a more direct way to debug this, but this may assist in uncovering whats happening

  • default discord avatar
    muperdev
    8 months ago

    yes, the problem is I cannot find out how to login there in the aws with the details they provide in the cloud setting

  • default discord avatar
    notchr
    8 months ago

    Ah I see



    This may require waiting for help from Payload - though they respond quickly. I'm running to lunch right now, but I can help more when I return. In the meantime, I'd check out how to trace the S3 log, once you do gain access

  • default discord avatar
    muperdev
    8 months ago

    you are my friend, thank you for your kindness



    @jesschow @denolfe if you know how to solve this it would be very great because we already in the production and the project goes very fast

  • default discord avatar
    notchr
    8 months ago

    @muperdev Any progress on this issue? Back from lunch

  • discord user avatar
    denolfe
    Payload Team
    8 months ago

    Hey @muperdev , looking at this now

  • default discord avatar
    muperdev
    8 months ago

    No not really, been searching for a while



    Thanks friend

  • discord user avatar
    denolfe
    Payload Team
    8 months ago

    Can you grab your project ID from Settings -> Billing? (Didn't see it above)

  • default discord avatar
    muperdev
    8 months ago

    Sure now



    643c23085fdfce9b59524a89



    here is the ID



    @denolfe

  • discord user avatar
    denolfe
    Payload Team
    8 months ago

    @muperdev I do not see any S3 bucket associated with your project (which means no assets have been uploaded). Can you paste the

    plugins

    section of your payload config?

  • default discord avatar
    muperdev
    8 months ago

    there's no plugin section actually



    that's what Im looking for



    I should add it as you mentioned above?

  • discord user avatar
    denolfe
    Payload Team
    8 months ago

    Yes, correct.

  • default discord avatar
    muperdev
    8 months ago

    let me

  • discord user avatar
    denolfe
    Payload Team
    8 months ago

    Add the package

    @payloadcms/plugin-cloud


    Then import it like the template-blank example above

  • default discord avatar
    muperdev
    8 months ago

    I added that version



    now I can simply add images to the website without any problem?



    or I need more configuration



    @denolfe



    it looks like it's fixed now



    thank you all guys for your help



    I think you better to mention it in cloud deployment that everybody needs to install this plugin before cloud deployment

  • discord user avatar
    denolfe
    Payload Team
    8 months ago

    Agreed, it's included in our cloud templates, but we definitely need to document this better 👍

  • default discord avatar
    muperdev
    8 months ago

    yes because you are the best CMS Provider out there, I want to see your company shining



    👏🏼



    also I have a problem in one of my other projects that it is already in cloud but isn't deploying because of a bug, could you help me in it? @denolfe

  • discord user avatar
    denolfe
    Payload Team
    8 months ago

    Sure, what are you running into?

  • default discord avatar
    muperdev
    8 months ago

    I have another project named "exolo" on the cloud and I cannot deploy it, I also opened a community help for it but can't find it anymore

  • discord user avatar
    denolfe
    Payload Team
    8 months ago

    Sure, project ID?

  • default discord avatar
    muperdev
    8 months ago

    6471bee2f198730ae31ecd5d



    here is the ID

  • discord user avatar
    denolfe
    Payload Team
    8 months ago

    Thanks, I'll be able to take a look in a bit

  • default discord avatar
    muperdev
    8 months ago

    @denolfe hey elliot, sorry for mentioning did you find any sollution for that case?



    @denolfe



    can you find out what is this error?



    it is for previous projec that we solved together

    image.png
  • discord user avatar
    denolfe
    Payload Team
    8 months ago

    Looking into this now 👍



    What payload and plugin-cloud version from package.json?



    @muperdev

  • default discord avatar
    muperdev
    8 months ago


    this is my version

    image.png
  • discord user avatar
    denolfe
    Payload Team
    8 months ago

    Ah, so plugin-cloud version 2 requires payload version 1.8.2 or greater.



    Two options to resolve this:



    - upgrade payload to 1.8.2


    - downgrade plugin-cloud to 1.x.x. However, that version does not have Payload Cloud email support.



    I'll look into why the peerDependencies on plugin-cloud didn't warn you about your Payload version.

  • default discord avatar
    muperdev
    8 months ago

    ok then what's the command to upgrade the payload?

  • discord user avatar
    denolfe
    Payload Team
    8 months ago
    yarn add payload@latest

    or

    npm install payload@latest
  • default discord avatar
    muperdev
    8 months ago

    that's fine will do that now

  • discord user avatar
    denolfe
    Payload Team
    8 months ago

    Okay, let me know if you run into anything else 👌

  • default discord avatar
    muperdev
    8 months ago

    think it's done, thank you for your help @denolfe



    @denolfe I lost my medias again after a while





    why is that for?



    can you find the reason



    also I like the song you're listening 🔥



    our project is in production and customers arguing for this bug that I don't know how to handle it



    would be good if you can help for that

    image.png
  • default discord avatar
    notchr
    8 months ago

    @muperdev can you confirm that your payload version updated correctly?



    What does your package.json list

  • default discord avatar
    muperdev
    8 months ago

    yes it's updated

  • default discord avatar
    notchr
    8 months ago

    What version does your package.json list?

  • default discord avatar
    muperdev
    8 months ago
    image.png
  • default discord avatar
    notchr
    8 months ago

    It looks like your payload version is acceptable hmm

  • default discord avatar
    muperdev
    8 months ago

    yes, but all pictures disappear after a while

  • default discord avatar
    notchr
    8 months ago

    Well, the pictures are still uploaded to your S3 bucket right



    It's just that the mongo DB loses reference, right?



    OR is your S3 bucket purging uploads?

  • default discord avatar
    muperdev
    8 months ago

    I guess so



    there's no way to troubleshoot since I don't have access to non of them

  • default discord avatar
    notchr
    8 months ago

    But for example, you see the images for a little while



    Does that mean those images got to S3



    ?



    Prior to deletion

  • default discord avatar
    muperdev
    8 months ago

    yes I guess, maybe it doesn't reach there and still in the mongo remains till mongo refresh the cluster then it lost all



    it's hard to troubleshoot without access but what you think?

  • default discord avatar
    notchr
    8 months ago

    Well, if you upload an image, can you then share the URL to that image



    it should have some indicitation it is being served from S3 or not, right?



    Versus something being served from your server



    I'm just trying to hlep you cross off some possibilities so we can narrow down what is happening

  • default discord avatar
    muperdev
    8 months ago
    https://panel.routepackers.com/media/Wyoming-location-map-1.jpeg


    Yes I feel you



    this is the url for one of our pictures



    https://panel.routepackers.com/media/car-shipping-on-road.webp


    this is the url that we cannot access through the website



    but it shows here



    dont know why

  • default discord avatar
    notchr
    8 months ago

    @muperdev sounds like a permission issue



    Can you open dev tools where the image wont load



    And show us any errors



    Or go to the Network tab in dev tools, find that image listed and the status



    and post it here

  • default discord avatar
    muperdev
    8 months ago

    yes





    404 is for permission, but the thing is why the permission allow me at the first, but after a while it blocks the access



    image.png
    image.png
  • default discord avatar
    notchr
    8 months ago

    hmm



    Well it would be a 403



    But it shows up here



    So the 404 is indeed confusing

  • default discord avatar
    muperdev
    8 months ago

    yes because not found is not related cause the picture is shows up here



    you think it might be for mongodb access?



    I set for public access to all urls

  • default discord avatar
    notchr
    8 months ago

    Shouldn't be, one sec



    And this is on production?

  • default discord avatar
    muperdev
    8 months ago

    yes

  • default discord avatar
    drew.id
    8 months ago

    It appears to be hitting cloudflare - could it be an issue there?

  • default discord avatar
    muperdev
    8 months ago

    you think cloudflare may make trouble?

  • discord user avatar
    denolfe
    Payload Team
    8 months ago

    @muperdev I'd like to confirm. You were able to see the image being served successfully at least once after upload?



    Are you able to see the image successfully if viewed in Payload admin?

  • default discord avatar
    muperdev
    8 months ago

    yes I saw it after 8 hours also



    no it is not there even



    that's not scary?



    but. it shows here

  • discord user avatar
    denolfe
    Payload Team
    8 months ago

    @muperdev I see your assets now. Which asset is the one that disappeared? Filename?



    So since the URL for the asset resolves at

    https://panel.routepackers.com/media/car-shipping-on-road.webp

    , that narrows it down a bit.



    Can you share your cors and csrf sections of your payload config?



    At this point, it feels like it must be something with your frontend.

  • default discord avatar
    muperdev
    8 months ago

    it shows now but it didn't before





    but not only in my frontend. didn't see even at the URL

    image.png
  • discord user avatar
    jmikrut
    Payload Team
    8 months ago

    can you link me to the page where you are seeing a broken image?



    you may need to whitelist your

    https://panel.routepackers.com

    domain as well as just the

    https://routepackers.com

    domain

  • default discord avatar
    muperdev
    8 months ago
    image.png
  • discord user avatar
    jmikrut
    Payload Team
    8 months ago

    strangely enough, it loads for me:



    image.png
  • default discord avatar
    muperdev
    8 months ago

    thank you for checking



    if it disappear again I'll let you know

Open the post
Continue the discussion in Discord
Like what we're doing?
Star us on GitHub!

Star

Connect with the Payload Community on Discord

Discord

online

Can't find what you're looking for?

Get help straight from the Payload team with an Enterprise License.