feat(base): 更新 CORS 配置以允许 tauri.localhost
- 在 MiddlewareCORS 函数中添加 "tauri.localhost" 到允许的域名列表 - 这个更改支持 Tauri 应用在本地开发时的跨域请求
This commit is contained in:
1
.vscode/launch.json
vendored
1
.vscode/launch.json
vendored
@@ -5,6 +5,7 @@
|
|||||||
"version": "0.2.0",
|
"version": "0.2.0",
|
||||||
"configurations": [
|
"configurations": [
|
||||||
|
|
||||||
|
|
||||||
{
|
{
|
||||||
"name": "Launch login-http",
|
"name": "Launch login-http",
|
||||||
"type": "go",
|
"type": "go",
|
||||||
|
|||||||
@@ -14,7 +14,7 @@ import (
|
|||||||
func MiddlewareCORS(r *ghttp.Request) {
|
func MiddlewareCORS(r *ghttp.Request) {
|
||||||
r.Response.CORSDefault()
|
r.Response.CORSDefault()
|
||||||
corsOptions := r.Response.DefaultCORSOptions()
|
corsOptions := r.Response.DefaultCORSOptions()
|
||||||
corsOptions.AllowDomain = []string{"*", "localhost"}
|
corsOptions.AllowDomain = []string{"*", "localhost", "tauri.localhost"}
|
||||||
if !r.Response.CORSAllowedOrigin(corsOptions) {
|
if !r.Response.CORSAllowedOrigin(corsOptions) {
|
||||||
r.Response.WriteStatus(http.StatusForbidden)
|
r.Response.WriteStatus(http.StatusForbidden)
|
||||||
return
|
return
|
||||||
|
|||||||
Reference in New Issue
Block a user