質問編集履歴
5
コードを修正
title
CHANGED
File without changes
|
body
CHANGED
@@ -27,7 +27,7 @@
|
|
27
27
|
func main() {
|
28
28
|
e := echo.New()
|
29
29
|
e.Use(middleware.CORS())
|
30
|
-
e.POST("/
|
30
|
+
e.POST("/login", Login)
|
31
31
|
}
|
32
32
|
|
33
33
|
func Login(c echo.Context) error {
|
4
コードを修正
title
CHANGED
File without changes
|
body
CHANGED
@@ -71,28 +71,4 @@
|
|
71
71
|
go 1.16
|
72
72
|
echo 4.4.0
|
73
73
|
axios 0.24.0
|
74
|
-
axios-hooks 2.7.0
|
74
|
+
axios-hooks 2.7.0
|
75
|
-
|
76
|
-
|
77
|
-
###追記
|
78
|
-
```go
|
79
|
-
loc, err := time.LoadLocation("Asia/Tokyo")
|
80
|
-
if err != nil {
|
81
|
-
loc = time.FixedZone("Asia/Tokyo", 9*60*60)
|
82
|
-
}
|
83
|
-
time.Local = loc
|
84
|
-
|
85
|
-
e.Use(middleware.CORSWithConfig(middleware.CORSConfig{
|
86
|
-
AllowOrigins: []string{"http://localhost:3000"},
|
87
|
-
AllowMethods: []string{http.MethodGet, http.MethodHead, http.MethodPut, http.MethodPatch, http.MethodPost, http.MethodDelete},
|
88
|
-
AllowCredentials: true,
|
89
|
-
}))
|
90
|
-
```
|
91
|
-
|
92
|
-
```
|
93
|
-
const axiosInstance = axios.create({
|
94
|
-
baseURL: 'http://localhost:8080',
|
95
|
-
withCredentials: true,
|
96
|
-
});
|
97
|
-
|
98
|
-
```
|
3
コードの追加
title
CHANGED
File without changes
|
body
CHANGED
@@ -53,7 +53,7 @@
|
|
53
53
|
import { configure } from 'axios-hooks'
|
54
54
|
|
55
55
|
const axiosInstance = axios.create({
|
56
|
-
baseURL: 'http://localhost:8080
|
56
|
+
baseURL: 'http://localhost:8080'
|
57
57
|
});
|
58
58
|
configure({cache:false, axios:axiosInstance });
|
59
59
|
|
@@ -71,4 +71,28 @@
|
|
71
71
|
go 1.16
|
72
72
|
echo 4.4.0
|
73
73
|
axios 0.24.0
|
74
|
-
axios-hooks 2.7.0
|
74
|
+
axios-hooks 2.7.0
|
75
|
+
|
76
|
+
|
77
|
+
###追記
|
78
|
+
```go
|
79
|
+
loc, err := time.LoadLocation("Asia/Tokyo")
|
80
|
+
if err != nil {
|
81
|
+
loc = time.FixedZone("Asia/Tokyo", 9*60*60)
|
82
|
+
}
|
83
|
+
time.Local = loc
|
84
|
+
|
85
|
+
e.Use(middleware.CORSWithConfig(middleware.CORSConfig{
|
86
|
+
AllowOrigins: []string{"http://localhost:3000"},
|
87
|
+
AllowMethods: []string{http.MethodGet, http.MethodHead, http.MethodPut, http.MethodPatch, http.MethodPost, http.MethodDelete},
|
88
|
+
AllowCredentials: true,
|
89
|
+
}))
|
90
|
+
```
|
91
|
+
|
92
|
+
```
|
93
|
+
const axiosInstance = axios.create({
|
94
|
+
baseURL: 'http://localhost:8080',
|
95
|
+
withCredentials: true,
|
96
|
+
});
|
97
|
+
|
98
|
+
```
|
2
コードの修正
title
CHANGED
File without changes
|
body
CHANGED
@@ -42,7 +42,7 @@
|
|
42
42
|
HttpOnly: true,
|
43
43
|
SameSite: http.SameSiteLaxMode,
|
44
44
|
}
|
45
|
-
c.SetCookie(
|
45
|
+
c.SetCookie(myCookie)
|
46
46
|
|
47
47
|
return c.NoContent(http.StatusOK)
|
48
48
|
}
|
1
文言の追加
title
CHANGED
File without changes
|
body
CHANGED
@@ -31,6 +31,8 @@
|
|
31
31
|
}
|
32
32
|
|
33
33
|
func Login(c echo.Context) error {
|
34
|
+
// 省略
|
35
|
+
|
34
36
|
myCookie := &http.Cookie{
|
35
37
|
Name: "token",
|
36
38
|
Value: "xxxxxxxx",
|