Skip to content
GitLab
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Sign in / Register
Toggle navigation
Menu
Open sidebar
何 广一
intern_project_backend
Commits
259824d7
Commit
259824d7
authored
Jun 23, 2025
by
IronHammer Std
Browse files
全都加上CORS
parent
e5308217
Changes
1
Hide whitespace changes
Inline
Side-by-side
Server.go
View file @
259824d7
...
@@ -37,6 +37,9 @@ var (
...
@@ -37,6 +37,9 @@ var (
// 发送统一格式的响应
// 发送统一格式的响应
func
sendResponse
(
w
http
.
ResponseWriter
,
code
int
,
msg
string
,
data
interface
{})
{
func
sendResponse
(
w
http
.
ResponseWriter
,
code
int
,
msg
string
,
data
interface
{})
{
w
.
Header
()
.
Set
(
"Content-Type"
,
"application/json"
)
w
.
Header
()
.
Set
(
"Content-Type"
,
"application/json"
)
w
.
Header
()
.
Set
(
"Access-Control-Allow-Origin"
,
"*"
)
w
.
Header
()
.
Set
(
"Access-Control-Allow-Methods"
,
"GET, POST, OPTIONS"
)
w
.
Header
()
.
Set
(
"Access-Control-Allow-Headers"
,
"Content-Type"
)
resp
:=
Response
{
resp
:=
Response
{
Code
:
code
,
Code
:
code
,
Msg
:
msg
,
Msg
:
msg
,
...
...
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment