wp-codespace icon indicating copy to clipboard operation
wp-codespace copied to clipboard

Doesn't work, endless redirection

Open cjohansson opened this issue 1 year ago • 3 comments

I started this according to instructions, after the build was completed I tried accessing port 80 for website, in my case the URL was: https://verbose-halibut-7vvjxqw67p2gqw-80.app.github.dev/

I got stuck in an endless redirection loop to https://verbose-halibut-7vvjxqw67p2gqw-443.app.github.dev/

Something in Wordpress is causing this because accessing a static file like https://verbose-halibut-7vvjxqw67p2gqw-80.app.github.dev/license.txt works and even accessing custom PHP files.

cjohansson avatar Aug 31 '23 14:08 cjohansson

I found a fix for this, you need to prepend this to wp-config.php:

<?php
if (
    !empty($_SERVER['HTTP_X_FORWARDED_PROTO']) 
    && $_SERVER['HTTP_X_FORWARDED_PROTO'] === 'https'
) {
    $_SERVER['HTTPS'] = 'on';
}
if (!empty($_SERVER['HTTP_X_FORWARDED_HOST'])) {
    $_SERVER['HTTP_HOST'] = $_SERVER['HTTP_X_FORWARDED_HOST'];
}
?>

To get it working with Wordpress on GitHub Codespaces.

cjohansson avatar Sep 01 '23 07:09 cjohansson

I am also having the same issue. The port says -80 but redirects to -443. The code above mentioned to be placed in the wp-config did not work either.

xBLADEx avatar Oct 07 '23 22:10 xBLADEx

Has anyone found a fix for this issue - I am experiencing it too and the solution suggested by @cjohansson doesn’t resolve it for me. :(

zagreusinoz avatar Feb 11 '24 17:02 zagreusinoz