google / site-kit-wp

Site Kit is a one-stop solution for WordPress users to use everything Google has to offer to make them successful on the web.
https://sitekit.withgoogle.com
Apache License 2.0
1.25k stars 291 forks source link

Cannot complete setup. Invalid URL error in console. #6211

Closed eoingroat closed 1 year ago

eoingroat commented 1 year ago

I recently had to install site-kit for our marketing team; while trying to use it we had the following error occur:

Failed to construct 'URL': Invalid URL

Some minor debugging found that it was trying to construct a URL of / or /wp-admin/admin.php?page=... and was failing because the URL was not fully qualified. A quick look round with the debugger and a peek at the source indicate that this is probably an issue with how the site is configured vs how site-kit expects.

The site is installed from the bitnami-wordpress image on google cloud marketplace; and as far as I'm aware no unusual config has occurred - our site health dump is below

I'm having them use a TamperScript for TamperMonkey to get round this issue for now. This allows them to sign in and use most things, but pagespeed insights is not fixed. All the script does is override the URL constructor with one that adds the current domain if no domain is present.

I presume there is an issue with our sites setup, but I couldn't see anythign.

Site Health I've redacted some information and placed `` where it was. ``` ### wp-core ### version: 6.1.1 site_language: en_GB user_language: en_GB timezone: Europe/London permalink: /%year%/%monthnum%/%day%/%postname%/ https_status: true multisite: false user_registration: 0 blog_public: 1 default_comment_status: undefined environment_type: production user_count: 12 dotorg_communication: true ### wp-paths-sizes ### wordpress_path: /opt/bitnami/wordpress wordpress_size: 1.08 GB (1164118520 bytes) uploads_path: /opt/bitnami/wordpress/wp-content/uploads uploads_size: 194.11 MB (203534464 bytes) themes_path: /opt/bitnami/wordpress/wp-content/themes themes_size: 18.33 MB (19218338 bytes) plugins_path: /opt/bitnami/wordpress/wp-content/plugins plugins_size: 193.61 MB (203015388 bytes) database_size: 1.42 GB (1526038528 bytes) total_size: 2.90 GB (3115925238 bytes) ### wp-dropins (1) ### advanced-cache.php: true ### wp-active-theme ### name: Hello Elementor (hello-elementor) version: 2.5.0 (latest version: 2.6.1) author: Elementor Team author_website: https://elementor.com/?utm_source=wp-themes&utm_campaign=author-uri&utm_medium=wp-dash parent_theme: none theme_features: core-block-patterns, widgets-block-editor, menus, post-thumbnails, automatic-feed-links, title-tag, html5, custom-logo, editor-style, align-wide, woocommerce, wc-product-gallery-zoom, wc-product-gallery-lightbox, wc-product-gallery-slider theme_path: /opt/bitnami/wordpress/wp-content/themes/hello-elementor auto_update: Disabled ### wp-themes-inactive (3) ### Stratus: version: 4.2.1, author: Themovation, Auto-updates disabled Twenty Twenty-Three: version: 1.0, author: the WordPress team, Auto-updates disabled Twenty Twenty-Two: version: 1.1, author: the WordPress team (latest version: 1.3), Auto-updates disabled ### wp-plugins-active (33) ### All in One SEO: version: 4.2.7.1, author: All in One SEO Team, Auto-updates enabled Converter for Media: version: 5.5.0, author: Image Optimization Team by matt plugins, Auto-updates enabled Duplicate Page: version: 4.4.9, author: mndpsingh287, Auto-updates enabled Elementor: version: 3.8.1, author: Elementor.com, Auto-updates enabled Elementor Pro: version: 3.8.2, author: Elementor.com, Auto-updates enabled Enable Media Replace: version: 4.0.1, author: ShortPixel, Auto-updates enabled Envato Market: version: 2.0.7, author: Envato, Auto-updates enabled EWD Premium Helper: version: 0.0.22, author: Etoile Web Design, Auto-updates enabled Formidable Forms: version: 5.5.3.1, author: Strategy11 Form Builder Team, Auto-updates enabled GDPR Cookie Consent: version: 2.3.8, author: WebToffee, Auto-updates enabled HubSpot All-In-One Marketing - Forms, Popups, Live Chat: version: 9.0.500, author: HubSpot, Auto-updates enabled Kirki Customizer Framework: version: 4.0.24, author: David Vongries, Auto-updates enabled Make Column Clickable Elementor: version: 1.4.0, author: Fernando Acosta, Auto-updates enabled Make Paths Relative: version: 1.3.0, author: YAS Global Team, Auto-updates enabled Marker.io: version: 1.1.5, author: Marker.io, Auto-updates enabled Members: version: 3.2.2, author: MemberPress, Auto-updates enabled Notification Bar Builder for Elementor: version: 1.0.3, author: AZ_Plugins, Auto-updates disabled 's Dynamic Elementor Templates: version: 1.0, author: RDK, Auto-updates disabled Euclid/Elixir Timeline Template: version: 1.4, author: RDK, Auto-updates disabled Page Builder Widget Pack: version: 2.1.13, author: Themovation, Auto-updates disabled Premium Addons for Elementor: version: 4.9.39, author: Leap13, Auto-updates enabled Remove Pointer from Blank Menu Items: version: 1.0.2.8, author: Worcester Web Studio, Auto-updates disabled Simple Page Ordering: version: 2.4.3, author: Jake Goldman, 10up, Auto-updates enabled Site Kit by Google: version: 1.87.0, author: Google (latest version: 1.88.0), Auto-updates disabled Ultimate FAQ - WordPress FAQ and Accordion Plugin: author: (undefined), version: 2.1.18, Auto-updates enabled Unlimited Elements for Elementor: version: 1.5.40, author: Unlimited Elements, Auto-updates enabled Website File Changes Monitor: version: 1.8.3, author: WP White Security, Auto-updates enabled Widget Logic: version: 5.10.4, author: WPChef, Auto-updates enabled Wordfence Security: version: 7.7.1, author: Wordfence, Auto-updates enabled WordPress Importer: version: 0.8, author: wordpressdotorg, Auto-updates enabled WP-Optimize - Clean, Compress, Cache: version: 3.2.9, author: David Anderson, Ruhani Rabin, Team Updraft, Auto-updates enabled WP Activity Log: version: 4.4.2.1, author: WP White Security, Auto-updates enabled WP Engine Automated Migration: version: 4.78, author: WPEngine, Auto-updates enabled ### wp-plugins-inactive (5) ### Web Stories: version: 1.27.0, author: Google, Auto-updates enabled Wonder 3D Carousel Pro: version: 4.2C, author: Magic Hills Pty Ltd, Auto-updates enabled WP-Sweep: version: 1.1.5, author: Lester 'GaMerZ' Chan, Auto-updates enabled WP Crowdsignal Forms: version: 1.5.15, author: Automattic, Auto-updates disabled WPS Cleaner: version: 1.6.8, author: WPServeur, NicolasKulka, wpformation, Auto-updates enabled ### wp-media ### image_editor: WP_Image_Editor_Imagick imagick_module_version: 1690 imagemagick_version: ImageMagick 6.9.10-23 Q16 x86_64 20190101 https://imagemagick.org imagick_version: 3.5.1 file_uploads: File uploads is turned off post_max_size: 80M upload_max_filesize: 80M max_effective_size: 80 MB max_file_uploads: 20 imagick_limits: imagick::RESOURCETYPE_AREA: 122 MB imagick::RESOURCETYPE_DISK: 1073741824 imagick::RESOURCETYPE_FILE: 49152 imagick::RESOURCETYPE_MAP: 512 MB imagick::RESOURCETYPE_MEMORY: 256 MB imagick::RESOURCETYPE_THREAD: 1 imagemagick_file_formats: 3FR, 3G2, 3GP, AAI, AI, ART, ARW, AVI, AVS, BGR, BGRA, BGRO, BIE, BMP, BMP2, BMP3, BRF, CAL, CALS, CANVAS, CAPTION, CIN, CIP, CLIP, CMYK, CMYKA, CR2, CRW, CUR, CUT, DATA, DCM, DCR, DCX, DDS, DFONT, DNG, DPX, DXT1, DXT5, EPDF, EPI, EPS, EPS2, EPS3, EPSF, EPSI, EPT, EPT2, EPT3, ERF, FAX, FILE, FITS, FRACTAL, FTP, FTS, G3, G4, GIF, GIF87, GRADIENT, GRAY, GRAYA, GROUP4, H, HALD, HDR, HEIC, HISTOGRAM, HRZ, HTM, HTML, HTTP, HTTPS, ICB, ICO, ICON, IIQ, INFO, INLINE, IPL, ISOBRL, ISOBRL6, J2C, J2K, JBG, JBIG, JNG, JNX, JP2, JPC, JPE, JPEG, JPG, JPM, JPS, JPT, JSON, K25, KDC, LABEL, M2V, M4V, MAC, MAGICK, MAP, MASK, MAT, MATTE, MEF, MIFF, MKV, MNG, MONO, MOV, MP4, MPC, MPEG, MPG, MRW, MSL, MTV, MVG, NEF, NRW, NULL, ORF, OTB, OTF, PAL, PALM, PAM, PATTERN, PBM, PCD, PCDS, PCL, PCT, PCX, PDB, PDF, PDFA, PEF, PES, PFA, PFB, PFM, PGM, PGX, PICON, PICT, PIX, PJPEG, PLASMA, PNG, PNG00, PNG24, PNG32, PNG48, PNG64, PNG8, PNM, PPM, PREVIEW, PS, PS2, PS3, PSB, PSD, PTIF, PWP, RADIAL-GRADIENT, RAF, RAS, RAW, RGB, RGBA, RGBO, RGF, RLA, RLE, RMF, RW2, SCR, SCT, SFW, SGI, SHTML, SIX, SIXEL, SPARSE-COLOR, SR2, SRF, STEGANO, SUN, TEXT, TGA, THUMBNAIL, TIFF, TIFF64, TILE, TIM, TTC, TTF, TXT, UBRL, UBRL6, UIL, UYVY, VDA, VICAR, VID, VIFF, VIPS, VST, WBMP, WEBP, WMV, WPG, X, X3F, XBM, XC, XCF, XPM, XPS, XV, XWD, YCbCr, YCbCrA, YUV gd_version: bundled (2.1.0 compatible) gd_formats: GIF, JPEG, PNG, WebP, BMP ghostscript_version: not available ### wp-server ### server_architecture: Linux 4.19.0-21-cloud-amd64 x86_64 httpd_software: nginx/1.21.3 php_version: 7.4.24 64bit php_sapi: fpm-fcgi max_input_variables: 1000 time_limit: 30 memory_limit: 1024M max_input_time: 60 upload_max_filesize: 80M php_post_max_size: 80M curl_version: 7.64.0 OpenSSL/1.1.1n suhosin: false imagick_availability: true pretty_permalinks: true htaccess_extra_rules: true ### wp-database ### extension: mysqli server_version: 10.3.31-MariaDB client_version: mysqlnd 7.4.24 max_allowed_packet: 16777216 max_connections: 151 ### wp-constants ### WP_HOME: https://.ai/ WP_SITEURL: https://.ai/ WP_CONTENT_DIR: /opt/bitnami/wordpress/wp-content WP_PLUGIN_DIR: /opt/bitnami/wordpress/wp-content/plugins WP_MEMORY_LIMIT: 40M WP_MAX_MEMORY_LIMIT: 1024M WP_DEBUG: false WP_DEBUG_DISPLAY: false WP_DEBUG_LOG: true SCRIPT_DEBUG: false WP_CACHE: true CONCATENATE_SCRIPTS: undefined COMPRESS_SCRIPTS: undefined COMPRESS_CSS: undefined WP_ENVIRONMENT_TYPE: Undefined DB_CHARSET: utf8 DB_COLLATE: undefined ### wp-filesystem ### wordpress: writable wp-content: writable uploads: writable plugins: writable themes: writable ### aioseo (1) ### noindexed: Search Page ### google-site-kit ### version: 1.87.0 php_version: 7.4.24 wp_version: 6.1.1 reference_url: https://.ai amp_mode: no site_status: connected-site user_status: authenticated verification_status: verified-file connected_user_count: 2 active_modules: site-verification, search-console, adsense, analytics, analytics-4, pagespeed-insights recoverable_modules: none required_scopes: openid: ✅ https://www.googleapis.com/auth/userinfo.profile: ✅ https://www.googleapis.com/auth/userinfo.email: ✅ https://www.googleapis.com/auth/siteverification: ✅ https://www.googleapis.com/auth/webmasters: ✅ https://www.googleapis.com/auth/adsense.readonly: ✅ https://www.googleapis.com/auth/analytics.readonly: ✅ capabilities: googlesitekit_authenticate: ✅ googlesitekit_setup: ✅ googlesitekit_view_posts_insights: ✅ googlesitekit_view_dashboard: ✅ googlesitekit_manage_options: ✅ googlesitekit_view_splash: ✅ googlesitekit_view_authenticated_dashboard: ✅ googlesitekit_view_wp_dashboard_widget: ✅ googlesitekit_view_admin_bar_menu: ✅ enabled_features: adsenseSetupV2: ✅ dashboardSharing: ⭕ ga4ActivationBanner: ⭕ ideaHubModule: ⭕ twgModule: ⭕ userInput: ⭕ search_console_property: https://.ai/ adsense_account_id: pub-106••••••••••••• adsense_client_id: ca-pub-106••••••••••••• adsense_account_status: ready adsense_site_status: ready-no-auto-ads adsense_use_snippet: yes adsense_web_stories_adunit_id: none analytics_account_id: 7249•••• analytics_property_id: UA-7249•••••• analytics_profile_id: 1149••••• analytics_use_snippet: no analytics_4_property_id: 3097926•• analytics_4_web_data_stream_id: 4269•••••• analytics_4_measurement_id: G-1M•••••••• analytics_4_use_snippet: yes ```
The TamperScript To use this script replace the `@match` directive with one pointing to your desired domain. ```js // ==UserScript== // @name SiteKit-URLFix // @description Fixes URL construct issues on wordpress - site kit can't find the sites URL for some reason. // @version 0.1 // @author Eoin Groat // @match http*://yourdomain.ai/* // @icon https://www.google.com/s2/favicons?sz=64&domain=yourdomain.ai // @grant none // ==/UserScript== // Acquire global - adapted from https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/globalThis function check(it) { // Math is known to exist as a global in every environment. return it && it.Math === Math && it; } const theRealGlobalObject = check(typeof globalThis === 'object' && globalThis) || check(typeof window === 'object' && window) || check(typeof self === 'object' && self) || check(typeof global === 'object' && global) || // This returns undefined when running in strict mode (function () { return this; })() || Function('return this')(); (function() { 'use strict'; // Expose the value as field in whatever way the current environment supports function makeGlobal(field, value) { Object.defineProperty(theRealGlobalObject, field, { value, enumerable: false, configurable: true, writable: true, }); return theRealGlobalObject[field]; } // Save the old URL constructor. const oldURL=theRealGlobalObject.URL; // Allow for on page debugging of URLs that have been modified (it doesn't save them past the current page - maybe add localstorage if we really care?) const fixedURLs = makeGlobal('SiteKit-URLFix-fixedURLs', []); // The "fixed" URL function. If an absolute path is given that is *not* prefixed with a domain then it should be auto-prefixed with the current site. function SiteKitURLFix(originalURL) { let fixedURL = null; if(originalURL.startsWith('/')) { fixedURL = window.location.origin + originalURL; fixedURLs.push({ originalURL, fixedURL }); console.log(`Site request fixed with SiteKit-URLFix:`, { originalURL, fixedURL }); } return new oldURL(fixedURL || originalURL); }; // Expose the fix and the debugging information to the global and window contexts. makeGlobal('URL', SiteKitURLFix); })(); ```

It would be great to get help with this

After that, it would be great to see about detecting if this affects a user and telling them! In our searches we found a few dozen people who had struggled looking for help and then just reinstalled or gone silent. Reinstalling isn't an option for us!

Thanks

adamdunnage commented 1 year ago

Hello @eoingroat thanks for getting in touch. We don't provide plugin support through GitHub so could I please ask you to open a support forum topic for this and we'd be more than happy to help you troubleshoot this issue you are facing there. I will close this issue but we can reopen here if this requires further investigation by a developer. Thanks a lot.