修改无referer时无法上传的bug

This commit is contained in:
MarSeventh
2024-07-20 21:57:01 +08:00
parent ab43ca0c2f
commit ef4c6b6f0e
2 changed files with 5 additions and 4 deletions

View File

@@ -19,8 +19,8 @@
- 上传显示实时上传进度
- 支持整体复制和单独复制(整体复制即将所有链接通过换行串联起来后复制)
- 上传后图片无需手动点击,可直接展示在管理页面中
- 支持API上传认证
- 支持访问域名限制
- 支持API上传认证(感谢[hl128k](https://github.com/hl128k)
- 支持访问域名限制(感谢[hl128k](https://github.com/hl128k)
## 3.Deployment

View File

@@ -24,8 +24,9 @@ function isAuthCodeDefined(authCode) {
export async function onRequestPost(context) { // Contents of context object
const { request, env, params, waitUntil, next, data } = context;
const referer = request.headers.get('Referer');
const authCode = new URLSearchParams(new URL(referer).search).get('authcode');
// const referer = request.headers.get('Referer');
// const authCode = new URLSearchParams(new URL(referer).search).get('authcode');
const authCode = new URL(request.url).searchParams.get('authcode');
const clonedRequest = request.clone();
if (isAuthCodeDefined(env.AUTH_CODE) && !isValidAuthCode(env.AUTH_CODE, authCode)) {
return new UnauthorizedException("error");