Simplify your stack and build anything. Or everything.
Build tomorrow’s web with a modern solution you truly own.
Code-based nature means you can build on top of it to power anything.
It’s time to take back your content infrastructure.

Media Get Access 404 Error

default discord avatar
muperdevlast year
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
    last year

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

  • default discord avatar
    jessesivonenlast year

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

  • default discord avatar
    muperdevlast year


    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
    jessesivonenlast year

    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
    muperdevlast year

    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
    jessesivonenlast year

    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
    muperdevlast year

    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
    last year

    check out the

    plugin-cloud-storage

    and the instructions here for s3

    https://github.com/payloadcms/plugin-cloud-storage#s3-adapter
  • default discord avatar
    muperdevlast year


    this error happens when I installed the plugin as the documentation



    @jesschow

    image.png
  • discord user avatar
    jesschow
    last year

    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
    muperdevlast year

    so what about the s3?



    I would not configure that?

  • discord user avatar
    jesschow
    last year

    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
    muperdevlast year

    ok I'll check it

  • discord user avatar
    denolfe
    last year

    @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
    muperdevlast year

    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
    notchrlast year

    But they did display prior?

  • default discord avatar
    muperdevlast year

    yes they did



    multiple times



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

  • default discord avatar
    notchrlast year

    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
    muperdevlast year

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

  • default discord avatar
    notchrlast year

    So you have access to the server hosting the content?



    like ssh access?

  • default discord avatar
    muperdevlast year

    I didn't try but it's S3



    here

  • default discord avatar
    notchrlast year

    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
    muperdevlast year

    let me find out how to login there



    stay with me but 😂

  • default discord avatar
    notchrlast year

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

  • default discord avatar
    muperdevlast year

    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
    notchrlast year

    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
    muperdevlast year

    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
    notchrlast year

    @muperdev Any progress on this issue? Back from lunch

  • discord user avatar
    denolfe
    last year

    Hey @muperdev , looking at this now

  • default discord avatar
    muperdevlast year

    No not really, been searching for a while



    Thanks friend

  • discord user avatar
    denolfe
    last year

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

  • default discord avatar
    muperdevlast year

    Sure now



    643c23085fdfce9b59524a89



    here is the ID



    @denolfe

  • discord user avatar
    denolfe
    last year

    @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
    muperdevlast year

    there's no plugin section actually



    that's what Im looking for



    I should add it as you mentioned above?

  • discord user avatar
    denolfe
    last year

    Yes, correct.

  • default discord avatar
    muperdevlast year

    let me

  • discord user avatar
    denolfe
    last year

    Add the package

    @payloadcms/plugin-cloud


    Then import it like the template-blank example above

  • default discord avatar
    muperdevlast year

    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
    last year

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

  • default discord avatar
    muperdevlast year

    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
    last year

    Sure, what are you running into?

  • default discord avatar
    muperdevlast year

    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
    last year

    Sure, project ID?

  • default discord avatar
    muperdevlast year

    6471bee2f198730ae31ecd5d



    here is the ID

  • discord user avatar
    denolfe
    last year

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

  • default discord avatar
    muperdevlast year

    @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
    last year

    Looking into this now 👍



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



    @muperdev

  • default discord avatar
    muperdevlast year


    this is my version

    image.png
  • discord user avatar
    denolfe
    last year

    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
    muperdevlast year

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

  • discord user avatar
    denolfe
    last year
    yarn add payload@latest

    or

    npm install payload@latest
  • default discord avatar
    muperdevlast year

    that's fine will do that now

  • discord user avatar
    denolfe
    last year

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

  • default discord avatar
    muperdevlast year

    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
    notchrlast year

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



    What does your package.json list

  • default discord avatar
    muperdevlast year

    yes it's updated

  • default discord avatar
    notchrlast year

    What version does your package.json list?

  • default discord avatar
    muperdevlast year
    image.png
  • default discord avatar
    notchrlast year

    It looks like your payload version is acceptable hmm

  • default discord avatar
    muperdevlast year

    yes, but all pictures disappear after a while

  • default discord avatar
    notchrlast year

    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
    muperdevlast year

    I guess so



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

  • default discord avatar
    notchrlast year

    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
    muperdevlast year

    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
    notchrlast year

    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
    muperdevlast year
    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
    notchrlast year

    @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
    muperdevlast year

    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
    notchrlast year

    hmm



    Well it would be a 403



    But it shows up here



    So the 404 is indeed confusing

  • default discord avatar
    muperdevlast year

    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
    notchrlast year

    Shouldn't be, one sec



    And this is on production?

  • default discord avatar
    muperdevlast year

    yes

  • default discord avatar
    drew.idlast year

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

  • default discord avatar
    muperdevlast year

    you think cloudflare may make trouble?

  • discord user avatar
    denolfe
    last year

    @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
    muperdevlast year

    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
    last year

    @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
    muperdevlast year

    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
    last year

    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
    muperdevlast year
    image.png
  • discord user avatar
    jmikrut
    last year

    strangely enough, it loads for me:



    image.png
  • default discord avatar
    muperdevlast year

    thank you for checking



    if it disappear again I'll let you know

Star on GitHub

Star

Chat on Discord

Discord

online

Can't find what you're looking for?

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