質問編集履歴
2
追記
test
CHANGED
File without changes
|
test
CHANGED
@@ -78,10 +78,30 @@
|
|
78
78
|
|
79
79
|
```
|
80
80
|
|
81
|
-
以下が発生している
|
81
|
+
以下が発生しているエラーメッセージです。
|
82
82
|
|
83
83
|
```
|
84
84
|
|
85
85
|
Access to XMLHttpRequest at 'http://localhost:7500/lessons?id=13' from origin 'null' has been blocked by CORS policy: No 'Access-Control-Allow-Origin' header is present on the requested resource.
|
86
86
|
|
87
87
|
```
|
88
|
+
|
89
|
+
サーバの以下のコードを
|
90
|
+
|
91
|
+
```go
|
92
|
+
|
93
|
+
http.HandleFunc("/lessons/", f)
|
94
|
+
|
95
|
+
```
|
96
|
+
|
97
|
+
次のコードに
|
98
|
+
|
99
|
+
```go
|
100
|
+
|
101
|
+
http.HandleFunc("/lessons", f)
|
102
|
+
|
103
|
+
```
|
104
|
+
|
105
|
+
変更すればブロックされないのですが「lessons/1」などのパスにもマッチさせたいため、できればサーバのコードを変更せずに解決したいと考えています。
|
106
|
+
|
107
|
+
よろしくお願いします。
|
1
自作のパッケージを削除
test
CHANGED
File without changes
|
test
CHANGED
@@ -54,17 +54,13 @@
|
|
54
54
|
|
55
55
|
"net/http"
|
56
56
|
|
57
|
-
|
58
|
-
|
59
|
-
"github.com/sk409/goconst"
|
60
|
-
|
61
57
|
)
|
62
58
|
|
63
59
|
|
64
60
|
|
65
61
|
func f(w http.ResponseWriter, r *http.Request) {
|
66
62
|
|
67
|
-
|
63
|
+
w.Header().Set("Access-Control-Allow-Origin", "*")
|
68
64
|
|
69
65
|
}
|
70
66
|
|