diff --git a/backend/controller/accapi.go b/backend/controller/accapi.go index 43deac4..ce45deb 100644 --- a/backend/controller/accapi.go +++ b/backend/controller/accapi.go @@ -81,14 +81,18 @@ func (ar *AccountRouter) LoginAccount(c *gin.Context) { domain := c.Request.Header.Get("Origin") // set-cookie + // 要求: + // 1. 调试模式时允许跨域 + // 2. 设置的域为请求的域 + // 3. 允许js修改 if gin.Mode() == gin.DebugMode { http.SetCookie(c.Writer, &http.Cookie{ Name: "access-token", Value: token, Path: "/", Domain: domain, - Secure: true, - SameSite: http.SameSiteNoneMode, + Secure: false, + SameSite: http.SameSiteLaxMode, HttpOnly: false, MaxAge: 3600, }) @@ -99,7 +103,7 @@ func (ar *AccountRouter) LoginAccount(c *gin.Context) { Value: token, Path: "/", Domain: domain, - Secure: true, + Secure: false, SameSite: http.SameSiteStrictMode, HttpOnly: false, MaxAge: 3600, diff --git a/frontend/config.json b/frontend/config.json deleted file mode 100644 index 24ad9eb..0000000 --- a/frontend/config.json +++ /dev/null @@ -1,3 +0,0 @@ -{ - "base_url": "" -} \ No newline at end of file diff --git a/frontend/src/main.js b/frontend/src/main.js index 7f336eb..c849848 100644 --- a/frontend/src/main.js +++ b/frontend/src/main.js @@ -23,17 +23,22 @@ app.use(store) app.use(VueCookies) // let config=require("../config.json"); -fetch('/config.json').then(response => response.json()).then(config => { - console.log(config) - store.commit('setBaseURL', config.base_url) -}).then(() => { - const axiosInstance = axios.create({ - withCredentials: true, - baseURL: store.state.base_url, - }) - app.config.globalProperties.$axios = { ...axiosInstance } +// fetch('/config.json').then(response => response.json()).then(config => { +// console.log(config) +// store.commit('setBaseURL', config.base_url) +// }).then(() => { +// const axiosInstance = axios.create({ +// withCredentials: true, +// baseURL: store.state.base_url, +// }) +// app.config.globalProperties.$axios = { ...axiosInstance } +// }) + +const axiosInstance = axios.create({ + withCredentials: true, + baseURL: store.state.base_url, }) - +app.config.globalProperties.$axios = { ...axiosInstance } registerPlugins(app)