#Media paths in MDX files break on 'astro build' in Netlify, but works fine locally

10 messages · Page 1 of 1 (latest)

craggy cradle
#

Media paths in MDX files break on astro build in Netlify, but works fine locally with npm run dev

In my package.json I have these versions:

"@astrojs/mdx": "^2.1.1",
"astro": "^4.0.7"

I'm using Astro's Portfolio starter. The front matter images load fine when I view them from within my work.astro route once built on Netlify, but none of my media from my assets folder in public loads in my MDX files including the same front matter image.

Here's a few of my paths look like in my MDX files:

"../assets/work-media/IXS-Odyssey/Odyssey Gameplay Trailer.mp4"

"../assets/work-media/OurFirstKiss/OurFirstKiss-AltControllers.png"

This is my website currently: https://treverberryman.com/work/ixs-odyssey-vr/

rustic edge
#

You might try an npm run build rather than an npm run dev. The process is different and it might give you a different error code. That's what I do when my Netlify deploy doesn't work.

craggy cradle
#

Thanks, I'll try that out

#

Darn, no luck @rustic edge

rustic edge
#

Have you tried putting the files in the public folder?

craggy cradle
#

That's where they are now, I also tried putting in them in the src folder

rustic edge
#

Looking at your code at https://treverberryman.com/work/ixs-odyssey-vr/, I see <video autoplay="autoplay" loop="loop" muted="muted" controls data-astro-cid-7qzxku2k> <source src="../assets/work-media/IXS-Odyssey/Odyssey Gameplay Trailer.mp4" type="video/mp4" data-astro-cid-7qzxku2k>. I calculate "../assets/work-media/IXS-Odyssey/Odyssey Gameplay Trailer.mp4" to be https://treverberryman.com/work/assets/work-media/IXS-Odyssey/Odyssey Gameplay Trailer.mp4, which gives a 404. If you change the source element to <source src="../../assets/work-media/IXS-Odyssey/Odyssey Gameplay Trailer.mp4," then it will link to https://treverberryman.com/assets/work-media/IXS-Odyssey/Odyssey Gameplay Trailer.mp4 and there is a video there. Or is that not the issue you are debugging?

craggy cradle
#

This might be the fix, going to make some changes, thank you

rustic edge
#

If that works and you keep the files in the public folder (good if you don't want Astro to process them), then you may want to change the src attribute to a simple src="/assets/work-media/IXS-Odyssey/Odyssey Gameplay Trailer.mp4"

craggy cradle
#

Thanks for the tip, that worked out ✅