server-command icon indicating copy to clipboard operation
server-command copied to clipboard

Server on `http://` returns `https://` links

Open alexander-akait opened this issue 6 years ago • 5 comments

If you have site on https and run php server on http the function get_site_icon_url return a link with https.

I think the problem here https://github.com/WordPress/WordPress/blob/master/wp-includes/general-template.php#L810, because WordPress should use here get_site_url() instead get_option( 'site_icon' ).

Maybe we can add filter on get_site_icon_url to fix it problem or we should fix it in WordPress?

alexander-akait avatar Feb 01 '19 12:02 alexander-akait

Same problem for wp_upload_dir so all images have https, maybe we can add more filters here https://github.com/wp-cli/server-command/blob/master/router.php?

alexander-akait avatar Feb 01 '19 13:02 alexander-akait

Worth noting that get_option( 'site_icon' ) just holds the ID of the site icon, not its URL. The actual URL is generated by wp_get_attachment_image_url() and then wp_get_attachment_url(), which uses the image URL stored in the attachment metadata in the database.

So the right filter in that case would probably be wp_get_attachment_url.

swissspidy avatar Feb 01 '19 14:02 swissspidy

@swissspidy yep, i find what wp_get_attachment_url use wp_upload_dir for getting host, so i think filter should in wp_upload_dir, it is fix all images urls

alexander-akait avatar Feb 01 '19 14:02 alexander-akait

I'm not sure this can be easily solved. You still have all the links that are stored throughout post content fields that point to https://.

Maybe a better approach would be to add a flag --adapt-scheme that filters the actual output to replace all https:// links pointing to the local server with http:// links?

schlessera avatar Feb 04 '19 05:02 schlessera

@schlessera we rewrite url in production, but for development mode will be great have valid url

alexander-akait avatar Feb 04 '19 10:02 alexander-akait