We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
I'm trying to pass the request as an argument from my worker's router to the durable object's function, but most of it is getting empty.
Specifically in my case, i need the headers to be passed for authentication purposes, and it is not serializable.
current mock: worker.js
import { error, json, Router } from "itty-router"; import { withDurables } from "itty-durable"; export { Counter } from "./Counter.durable.js"; const router = Router({ base: "/api/v1" }); router .all("*", withDurables()) .get("/Counter/:CounterId", async (request, env) => { const counter = Counter.get(id); return counter.handleRequest(request); }) .all("*", () => error(404, "Not found")); export default { fetch: async (request, env, ctx) => router .handle(request, env, ctx) .then(json) .catch(error) };
Counter.durable.js:
import { createDurable } from "itty-durable"; export class Counter extends createDurable({ autoReturn: true, autoPersist: true }) { constructor(state, env) { super(state, env); this.storage = state.storage; this.env = env; this.sessions = []; } async handleRequest(request) { const requestId = request.headers.get("X-REQUEST-ID"); ... <some authentication>
Made an ugly workaround that works, but i think it's better to solve internally: worker.js
return counter.handleRequest(request) -> return counter.handleRequest({...request, headers: Object.fromEntries(request.headers)});
and then on my durable object's file:
async handleRequest(request) { request.headers = new Headers(request.headers); const requestId = request.headers.get("X-REQUEST-ID"); ...
The text was updated successfully, but these errors were encountered:
No branches or pull requests
I'm trying to pass the request as an argument from my worker's router to the durable object's function, but most of it is getting empty.
Specifically in my case, i need the headers to be passed for authentication purposes, and it is not serializable.
current mock:
worker.js
Counter.durable.js:
Made an ugly workaround that works, but i think it's better to solve internally:
worker.js
and then on my durable object's file:
The text was updated successfully, but these errors were encountered: