Joker
Explore posts from serversError after adding kord dependency
After I added kord to my backend project it throws this error:
`
Version: 0.15.0
Exception in thread "main" java.lang.NoClassDefFoundError: io/ktor/client/plugins/contentnegotiation/ContentNegotiation
at com.skyrealm.networking.pelican.http.ConnectionBuilder.build$lambda$4(ConnectionBuilder.kt:26)
at io.ktor.client.HttpClientKt.HttpClient(HttpClient.kt:42)
at com.skyrealm.networking.pelican.http.ConnectionBuilder.build(ConnectionBuilder.kt:25)
at com.skyrealm.networking.pelican.http.ConnectionBuilder.<init>(ConnectionBuilder.kt:22)
at com.skyrealm.networking.pelican.PelicanHandler.<init>(PelicanHandler.kt:27)
at com.skyrealm.backend.Controller.start(Controller.kt:45)
at com.skyrealm.backend.MainKt.main(Main.kt:4)
at com.skyrealm.backend.MainKt$main$2.invoke(Main.kt)
at com.skyrealm.backend.MainKt$main$2.invoke(Main.kt)
at kotlin.coroutines.intrinsics.IntrinsicsKt__IntrinsicsJvmKt$createCoroutineUnintercepted$$inlined$createCoroutineFromSuspendFunction$IntrinsicsKt__IntrinsicsJvmKt$1.invokeSuspend(IntrinsicsJvm.kt:223)
at kotlin.coroutines.jvm.internal.BaseContinuationImpl.resumeWith(ContinuationImpl.kt:33)
at kotlin.coroutines.ContinuationKt.startCoroutine(Continuation.kt:115)
at kotlin.coroutines.jvm.internal.RunSuspendKt.runSuspend(RunSuspend.kt:19)
at com.skyrealm.backend.MainKt.main(Main.kt)
Caused by: java.lang.ClassNotFoundException: io.ktor.client.plugins.contentnegotiation.ContentNegotiation
at java.base/jdk.internal.loader.BuiltinClassLoader.loadClass(BuiltinClassLoader.java:641)
at java.base/jdk.internal.loader.ClassLoaders$AppClassLoader.loadClass(ClassLoaders.java:188)
at java.base/java.lang.ClassLoader.loadClass(ClassLoader.java:528)
... 14 more
Exception in thread "main" java.lang.NoClassDefFoundError: io/ktor/client/plugins/contentnegotiation/ContentNegotiation
at com.skyrealm.networking.pelican.http.ConnectionBuilder.build$lambda$4(ConnectionBuilder.kt:26)
at io.ktor.client.HttpClientKt.HttpClient(HttpClient.kt:42)
at com.skyrealm.networking.pelican.http.ConnectionBuilder.build(ConnectionBuilder.kt:25)
at com.skyrealm.networking.pelican.http.ConnectionBuilder.<init>(ConnectionBuilder.kt:22)
at com.skyrealm.networking.pelican.PelicanHandler.<init>(PelicanHandler.kt:27)
at com.skyrealm.backend.Controller.start(Controller.kt:45)
at com.skyrealm.backend.MainKt.main(Main.kt:4)
at com.skyrealm.backend.MainKt$main$2.invoke(Main.kt)
at com.skyrealm.backend.MainKt$main$2.invoke(Main.kt)
at kotlin.coroutines.intrinsics.IntrinsicsKt__IntrinsicsJvmKt$createCoroutineUnintercepted$$inlined$createCoroutineFromSuspendFunction$IntrinsicsKt__IntrinsicsJvmKt$1.invokeSuspend(IntrinsicsJvm.kt:223)
at kotlin.coroutines.jvm.internal.BaseContinuationImpl.resumeWith(ContinuationImpl.kt:33)
at kotlin.coroutines.ContinuationKt.startCoroutine(Continuation.kt:115)
at kotlin.coroutines.jvm.internal.RunSuspendKt.runSuspend(RunSuspend.kt:19)
at com.skyrealm.backend.MainKt.main(Main.kt)
Caused by: java.lang.ClassNotFoundException: io.ktor.client.plugins.contentnegotiation.ContentNegotiation
at java.base/jdk.internal.loader.BuiltinClassLoader.loadClass(BuiltinClassLoader.java:641)
at java.base/jdk.internal.loader.ClassLoaders$AppClassLoader.loadClass(ClassLoaders.java:188)
at java.base/java.lang.ClassLoader.loadClass(ClassLoader.java:528)
... 14 more
7 replies
Cookies not available in other Route
r.get("/login/:userId", async (c): Promise<Response> => {
const redirectUri = `${c.env.WORKER_BASE_URL}/callback`;
setCookie(c, "userId", c.req.param("userId"), {
secure: true,
sameSite: "None",
httpOnly: true,
domain: c.env.WORKER_BASE_URL,
});
console.log(getCookie(c, "userId"));
const spotifyAuthUrl =
`https://accounts.spotify.com/authorize?` +
`response_type=code&client_id=${c.env.SPOTIFY_CLIENT_ID}` +
`&scope=playlist-modify-public` +
`&redirect_uri=${redirectUri}`;
return Response.redirect(spotifyAuthUrl, 302);
});
router.get("/callback", async (c): Promise<Response> => {
const { env } = c;
const request = c.req;
const url = new URL(request.url);
const code = url.searchParams.get("code");
if (!code) {
return new Response("No code found", { status: 400 });
}
const userId = getCookie(c, "userId");
if (!userId) {
return new Response("No userId found", { status: 400 });
}
// set auth code to userId
await env.TUNE_STORE.put(userId, code);
console.log(code);
return new Response("Authorized");
});
r.get("/login/:userId", async (c): Promise<Response> => {
const redirectUri = `${c.env.WORKER_BASE_URL}/callback`;
setCookie(c, "userId", c.req.param("userId"), {
secure: true,
sameSite: "None",
httpOnly: true,
domain: c.env.WORKER_BASE_URL,
});
console.log(getCookie(c, "userId"));
const spotifyAuthUrl =
`https://accounts.spotify.com/authorize?` +
`response_type=code&client_id=${c.env.SPOTIFY_CLIENT_ID}` +
`&scope=playlist-modify-public` +
`&redirect_uri=${redirectUri}`;
return Response.redirect(spotifyAuthUrl, 302);
});
router.get("/callback", async (c): Promise<Response> => {
const { env } = c;
const request = c.req;
const url = new URL(request.url);
const code = url.searchParams.get("code");
if (!code) {
return new Response("No code found", { status: 400 });
}
const userId = getCookie(c, "userId");
if (!userId) {
return new Response("No userId found", { status: 400 });
}
// set auth code to userId
await env.TUNE_STORE.put(userId, code);
console.log(code);
return new Response("Authorized");
});
18 replies