Skip to content

Commit

Permalink
wp-now: Use localhost instead of 127.0.0.1 (#455)
Browse files Browse the repository at this point in the history
See [this
comment](WordPress/wordpress-playground#435 (comment)).

## What?

This PR changes the URL that `wp-now` listens on from `127.0.0.1` to
localhost.

## Why?

When I run `wp-now start` in WSL (a Windows virtual environment), it
listens on `127.0.0.1` (ipv4 address).
However, when I access the URL on the host OS, it resolves `to::1` (ipv6
address), so I believe this is why the server is unreachable.

## Testing Instructions

- run `nx preview wp-now start`
- Confirm that the console displays the expected logs: `Server running
at http://localhost:8881/`
- Confirm that the WordPress site is displayed when accessing
`http://localhost:8881/`.
- Conform that WordPress Address and Site Address settings are
`http://localhost:8881/`.
- Confirm that all resources such as CSS and JS are also loaded at this
URL and that no errors are output to the console.
  • Loading branch information
Pookie717 committed May 30, 2023
1 parent fe82000 commit a76e14b
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 2 deletions.
2 changes: 1 addition & 1 deletion packages/wp-now/src/config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ export interface WPEnvOptions {

async function getAbsoluteURL() {
const port = await portFinder.getOpenPort();
return `http://127.0.0.1:${port}`;
return `http://localhost:${port}`;
}

function getWpContentHomePath(projectPath: string, mode: string) {
Expand Down
2 changes: 1 addition & 1 deletion packages/wp-now/src/start-server.ts
Original file line number Diff line number Diff line change
Expand Up @@ -102,7 +102,7 @@ export async function startServer(
}
});

const url = `http://127.0.0.1:${port}/`;
const url = `http://localhost:${port}/`;
app.listen(port, () => {
output?.log(`Server running at ${url}`);
});
Expand Down

0 comments on commit a76e14b

Please sign in to comment.