Kush Patel
11/23/2020, 3:49 AMindex.html
when I visit <http://localhost:8080/index.html>
but what I would like to do is render the index.html
when I visit <http://localhost:8080/>
. Any insight would be helpful. Thanks!sdeleuze
11/23/2020, 4:24 PMsdeleuze
11/23/2020, 4:25 PMKush Patel
11/23/2020, 4:27 PMsdeleuze
11/23/2020, 4:27 PMKush Patel
11/23/2020, 4:28 PMsdeleuze
11/23/2020, 4:30 PMsdeleuze
11/23/2020, 4:30 PMsdeleuze
11/23/2020, 4:30 PMmustache()
for example.sdeleuze
11/23/2020, 4:31 PMsdeleuze
11/23/2020, 4:31 PMKush Patel
11/23/2020, 4:33 PMsdeleuze
11/23/2020, 4:34 PMsdeleuze
11/23/2020, 4:34 PMServerResponse.ok().render("index")
sdeleuze
11/23/2020, 4:34 PMKush Patel
11/23/2020, 4:35 PMsdeleuze
11/23/2020, 4:36 PMKush Patel
11/23/2020, 4:39 PMindex.html
) is copied to the spring gradle build/resources/static
folder. The goal is to use a single spring endpoint to render the react app server sideKush Patel
11/23/2020, 4:40 PMsdeleuze
11/23/2020, 4:42 PMsdeleuze
11/23/2020, 4:42 PMsdeleuze
11/23/2020, 4:43 PM/index.html
when /
is requested with redirect views, maybe that's what you try to achieve?Kush Patel
11/23/2020, 4:44 PMindex.html
when /
is requestedKush Patel
11/23/2020, 4:44 PMsdeleuze
11/23/2020, 4:45 PMKush Patel
11/23/2020, 4:47 PMKush Patel
11/23/2020, 4:56 PMKush Patel
11/23/2020, 4:56 PM@Configuration
class UiController {
@Bean
fun redirectToUiRoute() = router {
GET("/") {
ServerResponse.permanentRedirect(URI("/ui")).build()
}
GET("/ui") {
ServerResponse.ok()
.contentType(MediaType.TEXT_HTML)
.body(ClassPathResource("static/index.html"))
}
}
}
Kush Patel
11/23/2020, 4:57 PM/ui
or /
, it will render the react app server-sideKush Patel
11/23/2020, 5:03 PMval app: KofuApplication = webApplication {
webMvc {
converters {
resource()
}
router {
GET("/") {
ServerResponse.permanentRedirect(URI("/ui")).build()
}
GET("/ui") {
ServerResponse.ok()
.contentType(MediaType.TEXT_HTML)
.body(ClassPathResource("static/index.html"))
}
}
}
}