SignatureDoesNotMatch仅具有非英语字符

问题描述

后端是BackBlaze的S3 API,使用aws4fetch构建工作器。

n = 8
not a perfect cube
2 is the cube root of 8
2 is the cube root of 8
not a perfect cube
not a perfect cube
not a perfect cube
not a perfect cube
not a perfect cube
not a perfect cube

仅使用https://api.anislet.dev/b2/assets/Example.txt

的英语字符即可正常工作

但不能使用非英语字符,例如中文或日语。

https://api.anislet.dev/b2/assets/サンプル.txt

https://api.anislet.dev/b2/assets/示例.txt

请求失败:

import { AwsClient } from 'aws4fetch'

export async function backBlazeHandler(request) {
    let url = new URL(request.url)
    let uri = url.pathname.replace('/b2','')
    let uriArg = uri.split('/')

    url.hostname = B2_S3_BUCKET_PREFIX + uriArg[1] + '.' + B2_S3_ENDPOINT
    url.pathname = uri.replace(uriArg[1],'')
    console.log(url.href)

    let tempHtml = 'Hello World'

    const aws = new AwsClient({
        "accessKeyId": B2_ACCESS_KEY_ID,"secretAccessKey": B2_ACCESS_KEY_SECRET,"region": B2_S3_REGION
    })

    var signedRequest = await aws.sign(url)
    
    if (url.pathname === '/') {
        return new Response(tempHtml,{ headers: { 'Content-Type': 'text/html; charset=utf-8' }})
    } else {
        return await fetch(signedRequest)
    }
}

为什么会这样,我该如何解决(或者我可以解决这个问题?)

解决方法

暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!

如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。

小编邮箱:dio#foxmail.com (将#修改为@)