Can't found session
Unanswered
Burmese posted this in #help-forum
BurmeseOP
Hey, i cloned https://github.com/emmaboecker/mod-installer and while using it when i try to save mods
It says that the session is not found
I tried to got at http://141.94.37.234:3000/api/auth/session and i can see my session json with my info filed so idk why it saying that i don't find it
Here is the concerned code :
It says that the session is not found
https://next-auth.js.org/errors#client_fetch_error undefined {
error: {},
url: 'http://141.94.37.234:3000/api/auth/session',
message: undefined
}I tried to got at http://141.94.37.234:3000/api/auth/session and i can see my session json with my info filed so idk why it saying that i don't find it
Here is the concerned code :
set.tsimport type {NextApiRequest, NextApiResponse} from 'next'
import clientPromise from "../../../lib/mongodb";
import {getSession} from "next-auth/react";
import {Loader, Mod, ModProfile, Server} from "../../../types/modProfile";
import {Role} from "../../../types/role";
import {makeId} from "../../../lib/makeId";
export default async function handler(
req: NextApiRequest,
res: NextApiResponse
) {
if (req.method !== "POST") {
res.status(405).send({message: "Only POST requests allowed"})
return
}
const session = await getSession(res)
if (!session) {
res.status(401).end()
return
}
....1 Reply
BurmeseOP
UpdateModListButton.tsximport {Button} from "@mantine/core";
import {useModEditorContext} from "../ModEditor";
import {useRouter} from "next/router";
import {useNotifications} from "@mantine/notifications";
import {useState} from "react";
export function UpdateModListButton() {
const modStateContext = useModEditorContext()
const router = useRouter()
const notifications = useNotifications()
const [updating, setUpdating] = useState(false)
function updateModList() {
setUpdating(true)
modStateContext.modProfile.id = modStateContext.modProfile.name.toLowerCase().replaceAll(/[^\w]/g, "-")
fetch("/api/profile/set", {method: "POST", body: JSON.stringify(modStateContext.modProfile)}).then(response => {
if (response.status === 200) {
if (modStateContext.modProfile._id !== modStateContext.modProfile.oldkey || router.route.startsWith("/new")) {
response.json().then(value => {
router.replace(`/edit/${value._id}`).then(() => {
modStateContext.setModProfile(value)
})
})
}
notifications.showNotification({
color: "green",
message: `Your Mod-List ${modStateContext.modProfile.name} was updated`
})
} else if (response.status === 406) {
notifications.showNotification({
color: "red",
message: `You haven't filled out all required values yet`
})
} else {
notifications.showNotification({
color: "red",
message: `There was an error. Got response code: ${response.status}`
})
}
setUpdating(false)
})
}