Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
|
@@ -173,7 +173,16 @@ def cors_proxy():
|
|
| 173 |
"Access-Control-Allow-Methods": "GET, POST, PATCH, PUT, DELETE, OPTIONS",
|
| 174 |
},
|
| 175 |
)
|
| 176 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 177 |
url = request.args.get("url")
|
| 178 |
if not url:
|
| 179 |
return "url パラメータが必要です", 400
|
|
@@ -203,13 +212,14 @@ def cors_proxy():
|
|
| 203 |
forward_params = request.args.to_dict(flat=True)
|
| 204 |
forward_params.pop("url", None)
|
| 205 |
forward_params.pop("send", None)
|
| 206 |
-
|
| 207 |
resp = requests.request(
|
| 208 |
method=request.method,
|
| 209 |
url=url,
|
| 210 |
headers=headers,
|
| 211 |
data=request.get_data(),
|
| 212 |
params=forward_params,
|
|
|
|
| 213 |
timeout=300,
|
| 214 |
)
|
| 215 |
|
|
@@ -237,7 +247,15 @@ def cors_proxy_404(e):
|
|
| 237 |
k: v for k, v in request.args.items()
|
| 238 |
if k != "baseurl23896"
|
| 239 |
}
|
| 240 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 241 |
# 転送先URLを組み立て
|
| 242 |
target_url = baseurl.rstrip("/") + request.path
|
| 243 |
if forward_params:
|
|
@@ -252,7 +270,7 @@ def cors_proxy_404(e):
|
|
| 252 |
if k.lower() not in ["host", "content-length"]
|
| 253 |
},
|
| 254 |
data=request.get_data(),
|
| 255 |
-
cookies=
|
| 256 |
allow_redirects=False,
|
| 257 |
timeout=10,
|
| 258 |
)
|
|
|
|
| 173 |
"Access-Control-Allow-Methods": "GET, POST, PATCH, PUT, DELETE, OPTIONS",
|
| 174 |
},
|
| 175 |
)
|
| 176 |
+
# cookie パラメータ取得
|
| 177 |
+
cookie_param = request.args.get("cookie")
|
| 178 |
+
|
| 179 |
+
cookies = None
|
| 180 |
+
if cookie_param:
|
| 181 |
+
cookies = {}
|
| 182 |
+
for item in cookie_param.split(";"):
|
| 183 |
+
if "=" in item:
|
| 184 |
+
k, v = item.split("=", 1)
|
| 185 |
+
cookies[k.strip()] = v.strip()
|
| 186 |
url = request.args.get("url")
|
| 187 |
if not url:
|
| 188 |
return "url パラメータが必要です", 400
|
|
|
|
| 212 |
forward_params = request.args.to_dict(flat=True)
|
| 213 |
forward_params.pop("url", None)
|
| 214 |
forward_params.pop("send", None)
|
| 215 |
+
forward_params.pop("cookie", None)
|
| 216 |
resp = requests.request(
|
| 217 |
method=request.method,
|
| 218 |
url=url,
|
| 219 |
headers=headers,
|
| 220 |
data=request.get_data(),
|
| 221 |
params=forward_params,
|
| 222 |
+
cookies=cookies, # ←追加
|
| 223 |
timeout=300,
|
| 224 |
)
|
| 225 |
|
|
|
|
| 247 |
k: v for k, v in request.args.items()
|
| 248 |
if k != "baseurl23896"
|
| 249 |
}
|
| 250 |
+
cookie_param = request.args.get("cookie")
|
| 251 |
+
|
| 252 |
+
cookies = None
|
| 253 |
+
if cookie_param:
|
| 254 |
+
cookies = {}
|
| 255 |
+
for item in cookie_param.split(";"):
|
| 256 |
+
if "=" in item:
|
| 257 |
+
k, v = item.split("=", 1)
|
| 258 |
+
cookies[k.strip()] = v.strip()
|
| 259 |
# 転送先URLを組み立て
|
| 260 |
target_url = baseurl.rstrip("/") + request.path
|
| 261 |
if forward_params:
|
|
|
|
| 270 |
if k.lower() not in ["host", "content-length"]
|
| 271 |
},
|
| 272 |
data=request.get_data(),
|
| 273 |
+
cookies=cookies, # ←追加
|
| 274 |
allow_redirects=False,
|
| 275 |
timeout=10,
|
| 276 |
)
|