Skip to content

Commit 7f5883c

Browse files
committed
Fix AppHarnessProd to find 404.html under frontend_path prefix
When frontend_path is set, the build output (including 404.html) is nested under that prefix directory. Update the static file server to mirror what sirv does in real prod deployments.
1 parent 3c11451 commit 7f5883c

1 file changed

Lines changed: 6 additions & 1 deletion

File tree

reflex/testing.py

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1050,8 +1050,13 @@ def _run_frontend(self):
10501050
/ reflex.utils.prerequisites.get_web_dir()
10511051
/ reflex.constants.Dirs.STATIC
10521052
)
1053+
# When frontend_path is set, the build output (including 404.html) is
1054+
# nested under that prefix directory, mirroring what sirv does in real
1055+
# prod deployments (see PackageJson.Commands.get_prod_command).
1056+
frontend_path = reflex.config.get_config().frontend_path.strip("/")
1057+
error_dir = web_root / frontend_path if frontend_path else web_root
10531058
error_page_map = {
1054-
404: web_root / "404.html",
1059+
404: error_dir / "404.html",
10551060
}
10561061
with Subdir404TCPServer(
10571062
("", 0),

0 commit comments

Comments
 (0)