🐛 Konfigurert aksesskontroll mot backend
Co-authored-by: Sindre Kjelsrud <sindre.kjelsrud@nav.no> Co-authored-by: Markus A. R. Johansen <markus.aleksander.rakil.johansen@nav.no>
This commit is contained in:
parent
6d5cffe8c2
commit
a8446b6b73
4 changed files with 14 additions and 9 deletions
|
@ -26,4 +26,5 @@ dependencies {
|
|||
implementation("ch.qos.logback:logback-classic:$logback_version")
|
||||
testImplementation("io.ktor:ktor-server-tests-jvm:$ktor_version")
|
||||
testImplementation("org.jetbrains.kotlin:kotlin-test-junit:$kotlin_version")
|
||||
implementation("io.ktor:ktor-server-cors:$ktor_version")
|
||||
}
|
|
@ -7,7 +7,7 @@ import no.nav.helse.sprik.plugins.*
|
|||
|
||||
fun main() {
|
||||
embeddedServer(Netty, port = 8080, host = "0.0.0.0", module = Application::module)
|
||||
.start(wait = true)
|
||||
.start(wait = true)
|
||||
}
|
||||
|
||||
fun Application.module() {
|
||||
|
|
|
@ -1,10 +1,16 @@
|
|||
package no.nav.helse.sprik.plugins
|
||||
|
||||
import io.ktor.http.*
|
||||
import io.ktor.server.routing.*
|
||||
import io.ktor.server.response.*
|
||||
import io.ktor.server.application.*
|
||||
import io.ktor.server.plugins.cors.routing.*
|
||||
|
||||
fun Application.configureRouting() {
|
||||
install(CORS) {
|
||||
anyHost()
|
||||
allowMethod(HttpMethod.Get)
|
||||
}
|
||||
routing {
|
||||
get("/") {
|
||||
call.respondText("Hello World!")
|
||||
|
|
|
@ -5,21 +5,19 @@ import useSWR from "swr";
|
|||
|
||||
const fetcher = (url: any) => axios.get(url).then(res => res.data)
|
||||
|
||||
function fetching() {
|
||||
const {data, error, isLoading} = useSWR('http://0.0.0.0:8080/', fetcher);
|
||||
if (error) return <div>failed to load: {error.message}</div>
|
||||
if (isLoading) return <div>Loading...</div>
|
||||
return <div>{data.data}</div>
|
||||
}
|
||||
|
||||
export default function Home() {
|
||||
|
||||
const {data, error, isLoading} = useSWR('http://0.0.0.0:8080/', fetcher);
|
||||
console.log(data);
|
||||
|
||||
return (
|
||||
<main className="flex justify-center">
|
||||
<div className="w-1/2 flex flex-col gap-4 justify-center text-center">
|
||||
<Heading level="1" size="xlarge">Sprik</Heading>
|
||||
<Button variant="primary">Meld inn feil</Button>
|
||||
<Button variant="secondary">Meld inn funksjonalitetsønsker</Button>
|
||||
{fetching()}
|
||||
|
||||
{data ? <div>{data}</div> : <div>Laster</div>}
|
||||
</div>
|
||||
</main>
|
||||
)
|
||||
|
|
Reference in a new issue