Assets not loading (not found) in Bedrock installation in subdirectory


#1

Hi! I’ve installed Bedrock + Sage in a subdirectory and everything works (styles and scripts), except from some resources (images and fonts) that don’t load.

I have Bedrock installed in a subdirectory in my main domain, like this: domain.com/site. I noticed that the browser tries to load the resources from domain.com/app/themes/sage/dist, whereas the correct location is domain.com/site/app/themes/sage/dist.

I would greatly appreciate your help.


#2

What is WP_HOME is to in your .env for Bedrock? Also, check the wp_options table for home. It should be domain.com/site if you have Bedrock installed in the web root — which is not advisable because it potentially exposes .env. :no_good_woman:


#3

Thanks for your reply. WP_HOME is set to domain.com/site, and both siteurl and home in wp_options are set to domain.com/site/wp.


#4

Is it just images and fonts that are defined in the stylesheet that are not working? Or are <img>s not working either? What do the URLs in the stylesheets say? What is publicPath in {sage}/resources/assets/config.json set to?


#5

Just the images and fonts from the stylesheets. publicPath is set to /app/themes/sage.


#6

Set the publicPath to the actual public path to the theme: /site/web/app/themes/sage — or if that’s what your public path is for your dev environment run the following when you build for production:

$ SAGE_DIST_PATH=/site/web/app/themes/sage/dist/ yarn build:production

For reference:


#7

That solves the issue. Thank you very much.!