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.

Static images for blocks 404ing

default discord avatar
_sadajo_last year
5

I have some local images I want to use for the

imageURL

key for my blocks.



I have had them set like

/media/block-images/{{blockName}}.png

which was working, but now isn't.



I don't believe it's related to Payload, more likely a config issue. But I was wondering if there were some detailed docs on serving static assets in general?

  • default discord avatar
    notchrlast year

    Good morning

    @173581681058512897

    I think this is the most relevant documentation:

    https://payloadcms.com/docs/upload/overview#enabling-uploads

    Although, when serving content, depending on how your server is setup, you may need to create an nginx entry for the content



    Happy to expand on that, but let me know if that part of the doc is helpful

  • default discord avatar
    _sadajo_last year

    Thanks. I’ll see if I need to setup an entry in the server.js. The weird part is this was working before and looking at the logs for the server and payload config, nothing changed. I’ll investigate further 😊

  • default discord avatar
    notchrlast year

    Hmmm



    @173581681058512897

    Do the assets show as 404? Can you access the image url directly and do they show?



    Some other thoughts: Are the access controls for the upload collection set to allow public view?

  • default discord avatar
    _sadajo_last year

    No, the images 404. They are not part of an image collection as I want them to be served statically as the preview images for blocks, and they’re part of the repo. Before I was able to access them at /media/block-images/…



    I had to add

    app.use('/media', express.static(path.join(__dirname, 'media')));

    to the server.js



    Will try and dig into how this was working before

  • default discord avatar
    notchrlast year
    @173581681058512897

    Let me know if you run into any more issues, happy to help troubleshoot

Star on GitHub

Star

Chat on Discord

Discord

online

Can't find what you're looking for?

Get dedicated engineering support directly from the Payload team.