Uploads not rendering when using browsersync through `yarn start`

I have set up an instance of Sage using the Bedrocks WP frame work and served through Valet.

When using yarn start and running browersync, I am able to render images from scss or in html using the @asset() blade function. But I will also have some images coming from the WP backend through uploads. These will not render. I have inspected the url and it is correct with the localhost:3000 domain. If i navigate directly to that URL i get redrected to the home page. This only happens when going through the proxyUrl localhost:3000/app/uploads/example.png. When I just navigate to the devUrl like example.text/app/uploads/example.png the image renders fine.

Any idea what is happening? Thanks!

@asset() is only intended for use with files that are stored in your theme, not for WordPress uploads. If you’re looking for a Blade directive to use with images in the WordPress Media Library, you might look at @Log1x’s @image directive.

As for why your localhost links aren’t working, I’m not sure but my guess would be that BrowserSync isn’t aware of them/able to serve them correctly.

Thanks @alwaysblank

I am not using @asset() for uploads rendering. I know that is just for images in my theme folder. I was just saying that works fine. It is just the images from the uploads file.

The URL localhost:3000/app/uploads/example.png is not working but example.text/app/uploads/example.png does not. I figured it a browsersync or yarn issues, but I don’t know how to resolve it.

What does the network tab in your browser’s inspector show for the images? Is it just a 404, or some other more interesting response?

My other guess would be that it could have something to do w/ Valet, but unfortunately I’m not very familiar with Valet at all. You might try searching the forums to see if someone has run into similar issues.

@alwaysblank It is a 301, which is what happens when I navigato to the url directly. It redirects to the localhost:3000.

I’ll looks through the forums to see if there is an issue like that for valet. Maybe my .htaccess is messed up.

This topic was automatically closed after 42 days. New replies are no longer allowed.