I cannot get my worker working
I am following this tutorial and have edited the files, but cannot get them to the cloudflare worker, none of the terminal commands are working.
26 Replies
Which tutorial are you following? It doesn't say in your question
https://github.com/Erisa/discord-oidc-worker?tab=readme-ov-file
it seems simple but I cannot get it working
is it possable
@Erisa Whenever I try to upload it to cloudflare it does not save, any idea why?
✘ [ERROR] Build failed with 1 error:
18:17:28.623
18:17:28.623 worker.js:1:24: ERROR: Could not resolve "./config.json" 18:17:28.623
18:17:28.623
18:17:28.647 node:events:652 18:17:28.648 return this.listener.apply(this.target, arguments); 18:17:28.648 ^ 18:17:28.648
18:17:28.649 q [Error]: Error while executing user command. Exited with error code: 1 18:17:28.649 at ChildProcess.<anonymous> (/snapshot/dist/run-build.js) 18:17:28.649 at Object.onceWrapper (node:events:652:26) 18:17:28.649 at ChildProcess.emit (node:events:537:28) 18:17:28.649 at ChildProcess._handle.onexit (node:internal/child_process:291:12) 18:17:28.649
18:17:28.649 Node.js v18.5.0 18:17:28.659 Failed: build command exited with code: 1 18:17:29.503 Failed: error occurred while running build command
18:17:28.623 worker.js:1:24: ERROR: Could not resolve "./config.json" 18:17:28.623
18:17:28.623
18:17:28.647 node:events:652 18:17:28.648 return this.listener.apply(this.target, arguments); 18:17:28.648 ^ 18:17:28.648
18:17:28.649 q [Error]: Error while executing user command. Exited with error code: 1 18:17:28.649 at ChildProcess.<anonymous> (/snapshot/dist/run-build.js) 18:17:28.649 at Object.onceWrapper (node:events:652:26) 18:17:28.649 at ChildProcess.emit (node:events:537:28) 18:17:28.649 at ChildProcess._handle.onexit (node:internal/child_process:291:12) 18:17:28.649
18:17:28.649 Node.js v18.5.0 18:17:28.659 Failed: build command exited with code: 1 18:17:29.503 Failed: error occurred while running build command
You misssed these steps
ok
now I am getting
✘ [ERROR] Could not resolve "./config.json"
18:24:51.619
18:24:51.620 worker.js:1:24: 18:24:51.620 1 │ import * as config from './config.json' 18:24:51.620 ╵~~~
18:24:51.620
18:24:51.620
18:24:51.621 ✘ [ERROR] Build failed with 1 error: 18:24:51.621
18:24:51.622 worker.js:1:24: ERROR: Could not resolve "./config.json" 18:24:51.622
18:24:51.622
18:24:51.651 Failed: Error while executing user command. Exited with error code: 1 18:24:51.662 Failed: build command exited with code: 1 18:24:52.556 Failed: error occurred while running build command
18:24:51.620 worker.js:1:24: 18:24:51.620 1 │ import * as config from './config.json' 18:24:51.620 ╵
18:24:51.620
18:24:51.621 ✘ [ERROR] Build failed with 1 error: 18:24:51.621
18:24:51.622 worker.js:1:24: ERROR: Could not resolve "./config.json" 18:24:51.622
18:24:51.622
18:24:51.651 Failed: Error while executing user command. Exited with error code: 1 18:24:51.662 Failed: build command exited with code: 1 18:24:52.556 Failed: error occurred while running build command
thats the same error and it means the same thing: there is no
config.json
fileI uploaded it to the github repository I have cloudflare using but it does not show it in github on the web
you should do all the changes locally, dont push them to github
following all the steps in order and running the commands on your local machine terminal should work, dont add extra layers of complexity
when i was doing them on my computer it was just giving me error messages in the terminal for most of the commands
Should I be using Linux?
which error messages? the only one youve shown so far is related to config.json not existing, which wouldnt happen if you ran it in that folder you showed locally
windows should work fine, i dont see why not, ive just not tested it outside of mac and linux
'git' is not recognized as an internal or external command,
operable program or batch file.
install git: https://gitforwindows.org/
Git for Windows
We bring the awesome Git VCS to Windows
youll also need node.js: https://nodejs.org/en
Node.js — Run JavaScript Everywhere
Node.js® is a JavaScript runtime built on Chrome's V8 JavaScript engine.
X [ERROR] Build failed with 2 errors:
X [ERROR] Could not resolve "hono"
../discord-oidc-worker-main/discord-oidc-worker-main/worker.js:2:21:
2 │ import { Hono } from 'hono'
╵ ~~
You can mark the path "hono" as external to exclude it from the bundle, which will remove this
error.
X [ERROR] Could not resolve "jose"
../discord-oidc-worker-main/discord-oidc-worker-main/worker.js:3:22:
3 │ import * as jose from 'jose'
╵ ~~
You can mark the path "jose" as external to exclude it from the bundle, which will remove this
error.
you missed step 2 which is to run
npm install
npm error code ENOENT
npm error syscall open
npm error path C:\Windows\system32\package.json
npm error errno -4058
npm error enoent Could not read package.json: Error: ENOENT: no such file or directory, open 'C:\Windows\system32\package.json'
npm error enoent This is related to npm not being able to find a file.
npm error enoent
youre not in the right directory
dont run that in system32!
I'd recommend learning how to use a command-line terminal if you arent familiar with it, its a valuable skill even outside of the few commands needed for this
I ran it in a normal terminal window and this was the result
npm error code ENOENT
npm error syscall open
npm error path C:\Users\Nathan\package.json
npm error errno -4058
npm error enoent Could not read package.json: Error: ENOENT: no such file or directory, open 'C:\Users\Nathan\package.json'
npm error enoent This is related to npm not being able to find a file.
npm error enoent
Thankyou so much for helping!
thats still not the right directory, the
cd
part of step 1 is important
it needs to be inside the discord-oidc-worker
directorythankyou I did that and the worker is working, but when i try to login all i get is
Bad request.
thats the part that gets reeaaally complicated, I would go through the usage sections steps one by one and make sure everything is exactly as it should be
its working now, but I am getting
OIDC ERROR: Failed to exchange code for token. Make sure the client secret is correct.
undefined
from cloudflareusually means a different piece of the config or secrets is wrong
you can get slightly more info by using
npx wrangler tail
or streaming logs on the cloudflare dashboard, but its not always helpfulwhat is the preview id?
I got it to work, THANKYOU SO MUCH
no problem