Skip to content

Commit 346bda2

Browse files
committed
respect base_path when pre-rendering static routes
1 parent b6243d3 commit 346bda2

File tree

2 files changed

+11
-2
lines changed

2 files changed

+11
-2
lines changed

packages/cli/src/build/bundle.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -821,6 +821,7 @@ impl AppBundle {
821821
&self
822822
.server_exe()
823823
.context("Failed to find server executable")?,
824+
self.build.krate.config.web.app.base_path.as_ref(),
824825
)
825826
.await?;
826827
Ok(())

packages/cli/src/build/prerender.rs

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,10 @@ use std::{
99
};
1010
use tokio::process::Command;
1111

12-
pub(crate) async fn pre_render_static_routes(server_exe: &Path) -> anyhow::Result<()> {
12+
pub(crate) async fn pre_render_static_routes(
13+
server_exe: &Path,
14+
base_path: Option<&String>,
15+
) -> anyhow::Result<()> {
1316
// Use the address passed in through environment variables or default to localhost:9999. We need
1417
// to default to a value that is different than the CLI default address to avoid conflicts
1518
let ip = server_ip().unwrap_or_else(|| IpAddr::V4(Ipv4Addr::new(127, 0, 0, 1)));
@@ -20,6 +23,11 @@ pub(crate) async fn pre_render_static_routes(server_exe: &Path) -> anyhow::Resul
2023
// Borrow port and address so we can easily moe them into multiple tasks below
2124
let address = &address;
2225
let port = &port;
26+
let url = if let Some(base_path) = base_path {
27+
format!("http://{address}:{port}/{base_path}/api/static_routes")
28+
} else {
29+
format!("http://{address}:{port}/api/static_routes")
30+
};
2331

2432
tracing::info!("Running SSG at http://{address}:{port} for {server_exe:?}");
2533

@@ -48,7 +56,7 @@ pub(crate) async fn pre_render_static_routes(server_exe: &Path) -> anyhow::Resul
4856
);
4957

5058
let request = reqwest_client
51-
.post(format!("http://{address}:{port}/api/static_routes"))
59+
.post(&url)
5260
.body("{}".to_string())
5361
.send()
5462
.await;

0 commit comments

Comments
 (0)