File tree 1 file changed +13
-4
lines changed
backend/src/main/kotlin/no/nais/cloud/testnais/sandbox/bachelorurlforkorter
1 file changed +13
-4
lines changed Original file line number Diff line number Diff line change @@ -32,12 +32,21 @@ fun startAppServer(config: Config) {
32
32
post(" forkort" , UrlForkorterController ::forkort, Rolle .Alle )
33
33
get(" hentalle" , UrlForkorterController ::hentAlleMedMetadata, Rolle .Alle )
34
34
}
35
- get(" /" ) { ctx -> ctx.redirect(" /index.html" ) }
36
- get(" {korturl}" , UrlForkorterController ::redirect, Rolle .Alle )
35
+ get(" {korturl}" ) { ctx ->
36
+ if (ctx.pathParam(" korturl" ) == " index.html" ) {
37
+ val asset =
38
+ UrlForkorterController ::class .java.getResourceAsStream(" /public/index.html" )
39
+ if (asset != null ) {
40
+ ctx.contentType(" text/html" ).result(asset)
41
+ }
42
+ } else {
43
+ UrlForkorterController .redirect(ctx)
44
+ }
45
+ }
37
46
}
38
47
// TODO: Kun for lokal utvikling med hot reload
39
- javalinConfig.bundledPlugins.enableCors {cors ->
40
- cors.addRule {it.allowHost(" http://localhost:5173" )}
48
+ javalinConfig.bundledPlugins.enableCors { cors ->
49
+ cors.addRule { it.allowHost(" http://localhost:5173" ) }
41
50
}
42
51
}
43
52
You can’t perform that action at this time.
0 commit comments