Cоlе
12/23/2021, 10:23 PM.sign()
takes in a Uint8Array, as opposed to a string. You'll want something like this:
js
.sign(new TextEncoder().encode(env.JWT_PRIVATE_KEY));
Skye
12/24/2021, 3:53 AMsandeepsihari
12/24/2021, 4:44 AMTypeError: Key must be of type CryptoKey. Received an instance of Uint8Array
Cоlе
12/24/2021, 5:43 AMCоlе
12/24/2021, 5:46 AM_worker.js
it's basically identical to workers, but compiled using pagessandeepsihari
12/24/2021, 7:19 AMCоlе
12/24/2021, 7:34 AMCоlе
12/24/2021, 7:34 AMsandeepsihari
12/24/2021, 5:04 PMHS256
otherwise i will need private key for signing and public key for the verification.
token = await new jose.SignJWT({ phone: phone })
.setProtectedHeader({ alg: "HS256" })
.setIssuedAt()
.setIssuer(JWT_ISSUER)
.setAudience(JWT_AUDIENCE)
.setExpirationTime(JWT_EXPIRATION_TIME)
.sign(new TextEncoder("utf-8").encode(secret key));
Rhino233
12/25/2021, 7:18 PMErwin
12/26/2021, 11:58 PMRhino233
12/27/2021, 5:21 AMwonkrattle
12/27/2021, 5:23 AMwonkrattle
12/27/2021, 5:24 AMErisa | Support Engineer
12/27/2021, 5:26 AMErisa | Support Engineer
12/27/2021, 5:27 AMErwin
12/27/2021, 5:47 AMErwin
12/27/2021, 5:47 AMRhino233
12/27/2021, 6:24 AMErwin
12/27/2021, 8:56 AMMatt
12/28/2021, 1:16 AMJames
12/28/2021, 1:18 AMDeleted User
12/31/2021, 11:08 AMBeny
12/31/2021, 11:24 AMDeleted User
12/31/2021, 11:33 AMBeny
12/31/2021, 11:34 AMdfcowell
01/01/2022, 6:37 AMfetch
requests made from a function don't include a user-agent header? I built a function that consumes the Github API. It works locally with wrangler pages dev
, but when running on Cloudflare calls to Github fail with this error: Request forbidden by administrative rules. Please make sure your request has a User-Agent header (http://developer.github.com/v3/#user-agent-required). Check https://developer.github.com for other possible causes.
One way or another, something should change - either Wrangler should not send a UA header when running locally (so it matches the Workers behaviour) or Workers should send a UA header. Not sure what the expected behaviour is here. 🙂Erwin
01/01/2022, 7:45 AMdfcowell
01/01/2022, 8:01 AMdfcowell
01/01/2022, 8:04 AMdotenv -- cross-var npx wrangler@pages pages dev -k GITHUB -b GITHUB_CLIENT_ID=%GITHUB_CLIENT_ID% -b GITHUB_CLIENT_SECRET=%GITHUB_CLIENT_SECRET% -- npm run start