File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -25,9 +25,12 @@ php -d memory_limit=512M ../phd/render.php \
2525# Restart any existing server, then launch the new one in its own session so
2626# Ctrl+C in the debug terminal only kills the log tail below. The server keeps
2727# running until the next build replaces it (or the container shuts down).
28+ #
29+ # auto_prepend_file rewrites $_SERVER from the request's Host header so the PHP
30+ # format's $MYSITE-built URLs work behind Codespaces / other port forwarders.
2831LOG=" /tmp/php-server-${FORMAT} .log"
2932pkill -f ' php -S 0.0.0.0:8080' 2> /dev/null || true
30- setsid nohup php -S 0.0.0.0:8080 -t " $DOCROOT " \
33+ setsid nohup php -d " auto_prepend_file= $PREPEND " - S 0.0.0.0:8080 -t " $DOCROOT " \
3134 > " $LOG " 2>&1 < /dev/null &
3235SERVER_PID=$!
3336
Original file line number Diff line number Diff line change 1+ <?php
2+
3+ // This file rewrites $_SERVER from the request's Host header so the PHP
4+ // format's $MYSITE-built URLs work behind Codespaces / other port forwarders.
5+
6+ $ forwardedHttps = ($ _SERVER ['HTTP_X_FORWARDED_PROTO ' ] ?? '' ) === 'https ' ;
7+ $ hostHeader = $ _SERVER ['HTTP_X_FORWARDED_HOST ' ] ?? $ _SERVER ['HTTP_HOST ' ] ?? '' ;
8+
9+ if ($ hostHeader !== '' ) {
10+ $ _SERVER ['HTTP_HOST ' ] = $ hostHeader ;
11+ }
12+
13+ if ($ forwardedHttps ) {
14+ $ _SERVER ['HTTPS ' ] = 'on ' ;
15+ }
You can’t perform that action at this time.
0 commit comments