Codespace doesn't work with WordPress

I’m using Codespaces with the PHP-MariaDB vscode remote container configuration on a fresh fork of the WordPress repository.

I use PHP’s inbuilt webserver to fire up the application on the root WP folder. The wp install page loads on the forwarded port, but doesn’t load any of the additional assets because its trying to load them using http://localhost as the host name.

I actually manage to get past the initial install of WP but then the homepage just loads blank.

I can actually print stuff out on the index.php so it seems like an issue between the codespace and the forwarded port following and/or resolving links correctly.

Is there any workaround for this? It’d be mighty useful to be able to setup Codespaces for WordPress development.

I’ve got it working in a Codespace in a preliminary sort of way - your best bet is to run the install using WP-CLI in the postCreateCommand, with the URL generated using the CODESPACE_NAME env variable and whatever port you’re using. There are other things you can do like setting the WP_HOME and WP_SITEURL constants in wp-config.php which will work but it can have side effects, since you’re installing from scratch you might as well have it clean from the start.

Hello,

Thankyou for the advice. Certainly I’ll be having a look into this.

Are you able to send an example of the postCreateCommand you used?

It’s more to do with the details you used to create the config. Because I noticed I have to use 0.0.0.0 instead of localhost to successfully connect to the DB. Is this something you came across too?

Sorry I didn’t see this earlier, thought I’d be getting a notification of some sort and never checked back. We are still experimenting a bit with what image to use and trying to get XDebug running, but you can check out one of the PRs here: Try: Codespace using pre-built image by dinhtungdu · Pull Request #120 · 10up/simple-podcasting · GitHub