Effect CommunityEC
Effect Community15mo ago
9 replies
whatplan

Including Browser Credentials in HTTP Requests: Exploring Options and Security Concerns

Is it possible for there to be a native way to include browser credentials in external http requests
or to expose the internal tag for setting this option: https://github.com/Effect-TS/effect/blob/main/packages/platform/src/internal/fetchHttpClient.ts#L12C34-L12C81

const patchedClient = HttpClient.make((req, url, signal, fiber) =>
  Effect.gen(function* () {
    const context = yield* FiberRef.get(FiberRef.currentContext);
    context.unsafeMap.set("@effect/platform/FetchHttpClient/FetchOptions", {
      credentials: "include",
    });
    const actualClient = yield* HttpClient.HttpClient;
    const res = yield* actualClient.execute(req);
    yield* FiberRef.set(FiberRef.currentContext, context);
    return res;
  }).pipe(Effect.provide(FetchHttpClient.layer))
);


I only want to do this on certain requests (for obvious security reasons) but this feels insanely hacky
Was this page helpful?