diff --git a/next.config.js b/next.config.js index a843cbe..5b70c0d 100644 --- a/next.config.js +++ b/next.config.js @@ -1,6 +1,7 @@ /** @type {import('next').NextConfig} */ const nextConfig = { reactStrictMode: true, + // basePath: '/itsc', } module.exports = nextConfig diff --git a/pages/time.js b/pages/time.js index 07f36ae..878fa21 100644 --- a/pages/time.js +++ b/pages/time.js @@ -16,6 +16,9 @@ import { } from "@mui/material"; import { useEffect, useState } from "react"; import { useRouter } from "next/router"; +import config from '../next.config'; + +const prefix = config.basePath ? config.basePath : ''; export default function Time(props) { const [ranges, setRanges] = useState([]); @@ -30,7 +33,7 @@ export default function Time(props) { const router = useRouter(); const setStarted = (started) => { - fetch("/api/time/started", { + fetch(`${prefix}/api/time/started`, { method: "PUT", headers: { "Content-Type": "application/json", @@ -57,7 +60,7 @@ export default function Time(props) { }; const getLimit = () => { - fetch("/api/time/limit", { + fetch(`${prefix}/api/time/limit`, { method: "GET", headers: { "Content-Type": "application/json", @@ -70,7 +73,7 @@ export default function Time(props) { }; const addRange = () => { - fetch("/api/time/ranges", { + fetch(`${prefix}/api/time/ranges`, { method: "POST", headers: { "Content-Type": "application/json", @@ -95,7 +98,7 @@ export default function Time(props) { const refreshRanges = () => { getLimit(); - fetch("/api/time/ranges") + fetch(`${prefix}/api/time/ranges`) .then((res) => res.json()) .then((res) => { if (res.error) { @@ -108,7 +111,7 @@ export default function Time(props) { }; const deleteRange = (id) => { - fetch(`/api/time/ranges/${id}`, { + fetch(`${prefix}/api/time/ranges/${id}`, { method: "DELETE", headers: { "Content-Type": "application/json", @@ -128,7 +131,7 @@ export default function Time(props) { }; const updateUsername = (id, username) => { - fetch(`/api/time/ranges/${id}`, { + fetch(`${prefix}/api/time/ranges/${id}`, { method: "PUT", headers: { "Content-Type": "application/json", @@ -149,7 +152,7 @@ export default function Time(props) { }; const updateLimit = (limit) => { - fetch("/api/time/limit", { + fetch(`${prefix}/api/time/limit`, { method: "PUT", headers: { "Content-Type": "application/json",