Skip to content

Commit 73122f4

Browse files
authored
wp-now: Use localhost instead of 127.0.0.1 (#455)
See [this comment](#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.
1 parent 01357b9 commit 73122f4

File tree

2 files changed

+2
-2
lines changed

2 files changed

+2
-2
lines changed

packages/wp-now/src/config.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -64,7 +64,7 @@ export interface WPEnvOptions {
6464

6565
async function getAbsoluteURL() {
6666
const port = await portFinder.getOpenPort();
67-
return `http://127.0.0.1:${port}`;
67+
return `http://localhost:${port}`;
6868
}
6969

7070
function getWpContentHomePath(projectPath: string, mode: string) {

packages/wp-now/src/start-server.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -102,7 +102,7 @@ export async function startServer(
102102
}
103103
});
104104

105-
const url = `http://127.0.0.1:${port}/`;
105+
const url = `http://localhost:${port}/`;
106106
app.listen(port, () => {
107107
output?.log(`Server running at ${url}`);
108108
});

0 commit comments

Comments
 (0)