fix API URL prefix
This commit is contained in:
@@ -1,6 +1,7 @@
|
||||
/** @type {import('next').NextConfig} */
|
||||
const nextConfig = {
|
||||
reactStrictMode: true,
|
||||
// basePath: '/itsc',
|
||||
}
|
||||
|
||||
module.exports = nextConfig
|
||||
|
||||
@@ -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",
|
||||
|
||||
Reference in New Issue
Block a user