Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

404 on theme's assets, wrong path/URL #789

Open
alexandre-tobia opened this issue Jun 8, 2021 · 3 comments
Open

404 on theme's assets, wrong path/URL #789

alexandre-tobia opened this issue Jun 8, 2021 · 3 comments

Comments

@alexandre-tobia
Copy link

HI @leonstafford,

When generating static website, all of my static assets are not generated because of 404.

I've added logging line on your Crawler.php (L205) for showing the real URL used by the "getUrl" function:

if ( $response['code'] === 404 ) {
      $site_path = rtrim( SiteInfo::getURL( 'site' ), '/' );
      $url_slug = str_replace( $site_path, '', $url );
      WsLog::l( '404 for URL ' . $url_slug );

      WsLog::l( 'REAL URL ' . $url ); <===== HERE

      CrawlCache::rmUrl( $url_slug );
      $response['body'] = null;
  } elseif ( in_array( $response['code'], WP2STATIC_REDIRECT_CODES ) ) {
      $response['body'] = null;
  }

My wordpress site info:

site_path /Users/alexandretobia/Sites/nps/web/wp/
site_url http://nps.test/wp/
home_url http://nps.test/
includes_path /Users/alexandretobia/Sites/nps/web/wp/wp-includes/
includes_url http://nps.test/wp/wp-includes/
content_path /Users/alexandretobia/Sites/nps/web/app/
content_url http://nps.test/app/
uploads_path /Users/alexandretobia/Sites/nps/web/app/uploads/
uploads_url http://nps.test/app/uploads/
plugins_path /Users/alexandretobia/Sites/nps/web/app/plugins/
plugins_url http://nps.test/app/plugins/
themes_root_path /Users/alexandretobia/Sites/nps/web/app/themes/
themes_root_url http://nps.test/app/themes/
parent_theme_path /Users/alexandretobia/Sites/nps/web/app/themes/nps-wp/resources/
parent_theme_url http://nps.test/app/themes/nps-wp/resources/
child_theme_path /Users/alexandretobia/Sites/nps/web/app/themes/nps-wp/resources/
child_theme_url http://nps.test/app/themes/nps-wp/resources/

LOGS :
2021-06-08 13:01:58: REAL URL http://nps.test/Users/alexandretobia/Sites/nps/web/app/themes/nps-wp/resources/assets/styles/main.css
2021-06-08 13:01:58: 404 for URL /Users/alexandretobia/Sites/nps/web/app/themes/nps-wp/resources/assets/styles/main.css
2021-06-08 13:01:58: REAL URL http://nps.test/Users/alexandretobia/Sites/nps/web/app/themes/nps-wp/resources/assets/scripts/main.js
2021-06-08 13:01:58: 404 for URL /Users/alexandretobia/Sites/nps/web/app/themes/nps-wp/resources/assets/scripts/main.js
2021-06-08 13:01:58: REAL URL http://nps.test/Users/alexandretobia/Sites/nps/web/app/themes/nps-wp/resources/assets/mix-manifest.json
2021-06-08 13:01:58: 404 for URL /Users/alexandretobia/Sites/nps/web/app/themes/nps-wp/resources/assets/mix-manifest.json

I don't know why is he calling url like "http://nps.test/Users/alexandretobia/Sites/nps/web/app/themes/nps-wp/resources/assets/scripts/main.js"

Capture d’écran 2021-06-08 à 13 03 36

And a folder with "/Users/"...is created with corrupted files.

PHP version: 7.4.18
I'm using bedrock (roots.io)

Can you help me with that ?

Thanks a lot

@leonstafford
Copy link
Contributor

Thanks @alexandre-tobia! I don't have time right now to switch focus to it. Is there anyway with Bedrock to get the URL to not use a subdirectory for hosting? ie, drop the /wp and just serve WP from http://nps.test/? I think that wil be the main problem one. The /app/themes etc should be OK or a quicker fix.

@leonstafford
Copy link
Contributor

This gives some ideas: roots/bedrock#180

As WP2Static is designed to run off dev environments, I wouldn't care about the security implications of adjusting things against their project's best practices - as long as your dev server isn't open to the public.

@john-shaffer
Copy link
Contributor

#840 may help with this, once it's complete.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants