Skip to content

Commit 2c2c589

Browse files
committed
respect base_path when pre-renderin static routes
1 parent cb651a8 commit 2c2c589

File tree

1 file changed

+15
-3
lines changed

1 file changed

+15
-3
lines changed

packages/cli/src/cli/bundle.rs

Lines changed: 15 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -157,7 +157,11 @@ impl Bundle {
157157
if self.ssg {
158158
if let Some(server) = server.as_ref() {
159159
tracing::info!("Running SSG for static routes...");
160-
Self::pre_render_static_routes(&server.main_exe()).await?;
160+
Self::pre_render_static_routes(
161+
&server.main_exe(),
162+
client.config.web.app.base_path.as_ref(),
163+
)
164+
.await?;
161165
tracing::info!("SSG complete");
162166
} else {
163167
tracing::error!("SSG is only supported for fullstack apps. Ensure you have the server feature enabled and try again.");
@@ -290,14 +294,22 @@ impl Bundle {
290294
}
291295

292296
/// Pre-render the static routes, performing static-site generation
293-
async fn pre_render_static_routes(server_exe: &Path) -> anyhow::Result<()> {
297+
async fn pre_render_static_routes(
298+
server_exe: &Path,
299+
base_path: Option<&String>,
300+
) -> anyhow::Result<()> {
294301
// Use the address passed in through environment variables or default to localhost:9999. We need
295302
// to default to a value that is different than the CLI default address to avoid conflicts
296303
let ip = server_ip().unwrap_or_else(|| IpAddr::V4(Ipv4Addr::new(127, 0, 0, 1)));
297304
let port = server_port().unwrap_or(9999);
298305
let fullstack_address = SocketAddr::new(ip, port);
299306
let address = fullstack_address.ip().to_string();
300307
let port = fullstack_address.port().to_string();
308+
let url = if let Some(base_path) = base_path {
309+
format!("http://{address}:{port}/{base_path}/api/static_routes")
310+
} else {
311+
format!("http://{address}:{port}/api/static_routes")
312+
};
301313

302314
// Borrow port and address so we can easily moe them into multiple tasks below
303315
let address = &address;
@@ -330,7 +342,7 @@ impl Bundle {
330342
);
331343

332344
let request = reqwest_client
333-
.post(format!("http://{address}:{port}/api/static_routes"))
345+
.post(&url)
334346
.body("{}".to_string())
335347
.send()
336348
.await;

0 commit comments

Comments
 (0)