From fa1cbfbe981fc471c60b5ac17a22ad296c48b8c2 Mon Sep 17 00:00:00 2001 From: Thibaud Colas Date: Tue, 14 Feb 2023 11:17:58 +0000 Subject: [PATCH] Fix Storybook pattern library proxying in Node 18 --- client/storybook/middleware.js | 3 ++- docs/contributing/developing.md | 2 +- wagtail/test/settings_ui.py | 3 +++ 3 files changed, 6 insertions(+), 2 deletions(-) diff --git a/client/storybook/middleware.js b/client/storybook/middleware.js index 8c595681cd..ad64a5ff6f 100644 --- a/client/storybook/middleware.js +++ b/client/storybook/middleware.js @@ -1,7 +1,8 @@ /* eslint-disable @typescript-eslint/no-var-requires, import/no-extraneous-dependencies */ const middleware = require('storybook-django/src/middleware'); -const origin = process.env.TEST_ORIGIN ?? 'http://localhost:8000'; +// Target the Django server with IPV4 address explicitly to avoid DNS resolution of localhost to IPV6. +const origin = process.env.TEST_ORIGIN ?? 'http://127.0.0.1:8000'; module.exports = middleware.createDjangoAPIMiddleware({ origin, diff --git a/docs/contributing/developing.md b/docs/contributing/developing.md index 4161dc8dde..47cd6179c7 100644 --- a/docs/contributing/developing.md +++ b/docs/contributing/developing.md @@ -200,7 +200,7 @@ npm --prefix client/tests/integration install npm run test:integration ``` -Integration tests target `http://localhost:8000` by default. Use the `TEST_ORIGIN` environment variable to use a different port, or test a remote Wagtail instance: `TEST_ORIGIN=http://localhost:9000 npm run test:integration`. +Integration tests target `http://127.0.0.1:8000` by default. Use the `TEST_ORIGIN` environment variable to use a different port, or test a remote Wagtail instance: `TEST_ORIGIN=http://127.0.0.1:9000 npm run test:integration`. ### Browser and device support diff --git a/wagtail/test/settings_ui.py b/wagtail/test/settings_ui.py index 12bf4849c3..e19cf7c77d 100644 --- a/wagtail/test/settings_ui.py +++ b/wagtail/test/settings_ui.py @@ -9,6 +9,9 @@ INSTALLED_APPS += [ # noqa "pattern_library", ] +# Allow loopback address to access the server without DNS resolution (lack of Happy Eyeballs in Node 18). +ALLOWED_HOSTS += ["127.0.0.1"] # noqa + TEMPLATES[0]["OPTIONS"]["builtins"] = ["pattern_library.loader_tags"] # noqa PATTERN_LIBRARY = {