ValueMelody / melody-auth

A turnkey OAuth & authentication system, designed for both Cloudflare Workers and Node.js
https://auth.valuemelody.com/
MIT License
56 stars 3 forks source link

The command npm run prod:secret:generate fails to execute in a proxy environment. #184

Closed shydow closed 4 weeks ago

shydow commented 1 month ago

Problem Analysis:

On line 104 of [melody-auth/server/src/scripts/generate-secret.cjs]:

the command [wrangler kv key list --prefix=sessionSecret --binding=KV ${condition}] is causing an issue when executed in a proxy environment.

The first line of the output indicates that a proxy environment has been detected: "Proxy environment variables detected. We'll use your proxy for fetch requests."

byn9826 commented 1 month ago

Can you indicate what is your exact env? OS, node version, etc

shydow commented 1 month ago

OS: ubuntu 24.04 LTS node version: v22.9.0 browser: chrome

byn9826 commented 1 month ago

Can you paste all the outputs? "Use proxy for fetch requests" doesn't looks like the cause of the issue.

Also "prod:secret:generate" is storing value to Cloudflare KV, have you logged into Cloudflare through cli and replaced kv id in wrangler with your own kv id? Have you encouter any issue with "dev:secret:generate" or "node:secret:generate"?

shydow commented 1 month ago

output of generate command:

> prod:secret:generate
> node ./src/scripts/generate-secret.cjs prod

SyntaxError: Unexpected token 'P', "Proxy envi"... is not valid JSON
    at JSON.parse (<anonymous>)
    at generateRSAKeyPair (/home/shydow/workspace/melody-auth/server/src/scripts/generate-secret.cjs:104:37)

the orginal wrangler command output is like:

❯ npx wrangler kv key list --prefix=jwtPublicSecret --binding=KV --local
Proxy environment variables detected. We'll use your proxy for fetch requests.
[]
byn9826 commented 4 weeks ago

Looks similar to https://github.com/cloudflare/workers-sdk/issues/4515. In a proxy env, wrangler will output this extra message, which messed the expected output format.

By proxy env, are you using a vpn or something?

shydow commented 4 weeks ago

Looks similar to cloudflare/workers-sdk#4515. In a proxy env, wrangler will output this extra message, which messed the expected output format.

yes, you are right.

By proxy env, are you using a vpn or something?

I use the proxy by setting the environment variable

export HTTP_PROXY=xxxx
byn9826 commented 4 weeks ago

Check if #185 fix your issue

shydow commented 4 weeks ago

Excellent work. The bug has been successfully resolved.