diff --git a/Taipei-City-Dashboard-FE/src/router/axios.js b/Taipei-City-Dashboard-FE/src/router/axios.js index f731271f..3929a163 100644 --- a/Taipei-City-Dashboard-FE/src/router/axios.js +++ b/Taipei-City-Dashboard-FE/src/router/axios.js @@ -4,9 +4,10 @@ // This file centrally handles all axios requests made in the application. import axios from "axios"; -import { usePersonStore } from "../store/personStore"; +import { usePersonStore } from "../store/personStore.js"; import { useDialogStore } from "../store/dialogStore"; import { useContentStore } from "../store/contentStore"; +import { DataManager } from "../assets/utilityFunctions/dataManager.js"; const http = axios.create({ baseURL: import.meta.env.VITE_API_URL, @@ -23,8 +24,8 @@ http.interceptors.request.use((request) => { contentStore.loading = true; contentStore.error = false; - if (personStore.token) { - request.headers.setAuthorization(`Bearer ${personStore.token}`); + if (personStore.code) { + request.headers.setAuthorization(`Bearer ${personStore.code}`); } else { request.headers.setAuthorization(`Bearer`); } @@ -36,9 +37,11 @@ http.interceptors.response.use( (response) => { // handle loading directly in request since sometimes requests are stringed together const personStore = usePersonStore(); - if (response.data.token) { - personStore.token = response.data.token; - localStorage.setItem("token", response.data.token); + const dataManager = new DataManager(response.data); + + if (dataManager.getData("data")) { + personStore.code = dataManager.getData("data"); + localStorage.setItem("code", personStore.code); } return response; }, @@ -52,7 +55,7 @@ http.interceptors.response.use( switch (error.response.status) { case 401: - if (personStore.token) { + if (personStore.code) { dialogStore.showNotification( "fail", "401,登入逾時,請重新登入" @@ -66,7 +69,7 @@ http.interceptors.response.use( } break; case 403: - if (personStore.token) { + if (personStore.code) { dialogStore.showNotification( "fail", "403,沒有權限執行此動作" diff --git a/Taipei-City-Dashboard-FE/src/store/mapStore.js b/Taipei-City-Dashboard-FE/src/store/mapStore.js index 5b33a515..08b95405 100644 --- a/Taipei-City-Dashboard-FE/src/store/mapStore.js +++ b/Taipei-City-Dashboard-FE/src/store/mapStore.js @@ -130,7 +130,12 @@ export const useMapStore = defineStore("map", { const personStore = usePersonStore(); if (!this.map) return; // Taipei District Labels - fetch(`/mapData/taipei_town.geojson`) + fetch(`/mapData/taipei_town.geojson`, { + method: 'GET', + headers: { + 'Strict-Transport-Security': 'max-age=31536000; includeSubDomains' + } + }) .then((response) => response.json()) .then((data) => { this.map @@ -141,7 +146,12 @@ export const useMapStore = defineStore("map", { .addLayer(TaipeiTown); }); // Taipei Village Labels - fetch(`/mapData/taipei_village.geojson`) + fetch(`/mapData/taipei_village.geojson`, { + method: 'GET', + headers: { + 'Strict-Transport-Security': 'max-age=31536000; includeSubDomains' + } + }) .then((response) => response.json()) .then((data) => { this.map