fix API URL prefix
This commit is contained in:
@@ -1,6 +1,7 @@
|
|||||||
/** @type {import('next').NextConfig} */
|
/** @type {import('next').NextConfig} */
|
||||||
const nextConfig = {
|
const nextConfig = {
|
||||||
reactStrictMode: true,
|
reactStrictMode: true,
|
||||||
|
// basePath: '/itsc',
|
||||||
}
|
}
|
||||||
|
|
||||||
module.exports = nextConfig
|
module.exports = nextConfig
|
||||||
|
|||||||
@@ -16,6 +16,9 @@ import {
|
|||||||
} from "@mui/material";
|
} from "@mui/material";
|
||||||
import { useEffect, useState } from "react";
|
import { useEffect, useState } from "react";
|
||||||
import { useRouter } from "next/router";
|
import { useRouter } from "next/router";
|
||||||
|
import config from '../next.config';
|
||||||
|
|
||||||
|
const prefix = config.basePath ? config.basePath : '';
|
||||||
|
|
||||||
export default function Time(props) {
|
export default function Time(props) {
|
||||||
const [ranges, setRanges] = useState([]);
|
const [ranges, setRanges] = useState([]);
|
||||||
@@ -30,7 +33,7 @@ export default function Time(props) {
|
|||||||
const router = useRouter();
|
const router = useRouter();
|
||||||
|
|
||||||
const setStarted = (started) => {
|
const setStarted = (started) => {
|
||||||
fetch("/api/time/started", {
|
fetch(`${prefix}/api/time/started`, {
|
||||||
method: "PUT",
|
method: "PUT",
|
||||||
headers: {
|
headers: {
|
||||||
"Content-Type": "application/json",
|
"Content-Type": "application/json",
|
||||||
@@ -57,7 +60,7 @@ export default function Time(props) {
|
|||||||
};
|
};
|
||||||
|
|
||||||
const getLimit = () => {
|
const getLimit = () => {
|
||||||
fetch("/api/time/limit", {
|
fetch(`${prefix}/api/time/limit`, {
|
||||||
method: "GET",
|
method: "GET",
|
||||||
headers: {
|
headers: {
|
||||||
"Content-Type": "application/json",
|
"Content-Type": "application/json",
|
||||||
@@ -70,7 +73,7 @@ export default function Time(props) {
|
|||||||
};
|
};
|
||||||
|
|
||||||
const addRange = () => {
|
const addRange = () => {
|
||||||
fetch("/api/time/ranges", {
|
fetch(`${prefix}/api/time/ranges`, {
|
||||||
method: "POST",
|
method: "POST",
|
||||||
headers: {
|
headers: {
|
||||||
"Content-Type": "application/json",
|
"Content-Type": "application/json",
|
||||||
@@ -95,7 +98,7 @@ export default function Time(props) {
|
|||||||
|
|
||||||
const refreshRanges = () => {
|
const refreshRanges = () => {
|
||||||
getLimit();
|
getLimit();
|
||||||
fetch("/api/time/ranges")
|
fetch(`${prefix}/api/time/ranges`)
|
||||||
.then((res) => res.json())
|
.then((res) => res.json())
|
||||||
.then((res) => {
|
.then((res) => {
|
||||||
if (res.error) {
|
if (res.error) {
|
||||||
@@ -108,7 +111,7 @@ export default function Time(props) {
|
|||||||
};
|
};
|
||||||
|
|
||||||
const deleteRange = (id) => {
|
const deleteRange = (id) => {
|
||||||
fetch(`/api/time/ranges/${id}`, {
|
fetch(`${prefix}/api/time/ranges/${id}`, {
|
||||||
method: "DELETE",
|
method: "DELETE",
|
||||||
headers: {
|
headers: {
|
||||||
"Content-Type": "application/json",
|
"Content-Type": "application/json",
|
||||||
@@ -128,7 +131,7 @@ export default function Time(props) {
|
|||||||
};
|
};
|
||||||
|
|
||||||
const updateUsername = (id, username) => {
|
const updateUsername = (id, username) => {
|
||||||
fetch(`/api/time/ranges/${id}`, {
|
fetch(`${prefix}/api/time/ranges/${id}`, {
|
||||||
method: "PUT",
|
method: "PUT",
|
||||||
headers: {
|
headers: {
|
||||||
"Content-Type": "application/json",
|
"Content-Type": "application/json",
|
||||||
@@ -149,7 +152,7 @@ export default function Time(props) {
|
|||||||
};
|
};
|
||||||
|
|
||||||
const updateLimit = (limit) => {
|
const updateLimit = (limit) => {
|
||||||
fetch("/api/time/limit", {
|
fetch(`${prefix}/api/time/limit`, {
|
||||||
method: "PUT",
|
method: "PUT",
|
||||||
headers: {
|
headers: {
|
||||||
"Content-Type": "application/json",
|
"Content-Type": "application/json",
|
||||||
|
|||||||
Reference in New Issue
Block a user