@@ -157,7 +157,11 @@ impl Bundle {
157
157
if self . ssg {
158
158
if let Some ( server) = server. as_ref ( ) {
159
159
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 ?;
161
165
tracing:: info!( "SSG complete" ) ;
162
166
} else {
163
167
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 {
290
294
}
291
295
292
296
/// 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 < ( ) > {
294
301
// Use the address passed in through environment variables or default to localhost:9999. We need
295
302
// to default to a value that is different than the CLI default address to avoid conflicts
296
303
let ip = server_ip ( ) . unwrap_or_else ( || IpAddr :: V4 ( Ipv4Addr :: new ( 127 , 0 , 0 , 1 ) ) ) ;
297
304
let port = server_port ( ) . unwrap_or ( 9999 ) ;
298
305
let fullstack_address = SocketAddr :: new ( ip, port) ;
299
306
let address = fullstack_address. ip ( ) . to_string ( ) ;
300
307
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
+ } ;
301
313
302
314
// Borrow port and address so we can easily moe them into multiple tasks below
303
315
let address = & address;
@@ -330,7 +342,7 @@ impl Bundle {
330
342
) ;
331
343
332
344
let request = reqwest_client
333
- . post ( format ! ( "http://{address}:{port}/api/static_routes" ) )
345
+ . post ( & url )
334
346
. body ( "{}" . to_string ( ) )
335
347
. send ( )
336
348
. await ;
0 commit comments