UNPKG

@arcjet/transport

Version:

Transport mechanisms for the Arcjet protocol

28 lines (25 loc) 1.05 kB
import { createConnectTransport } from '@connectrpc/connect-web'; // This file is used when running on the `edge-light` condition. // Specifically Edge by Vercel. // It is the same as `workerd.ts`, which runs on Cloudflare. // It uses DOM based APIs (`@connectrpc/connect-web`) to connect to the API. // Differing from `bun.ts` this solves the `redirect` option set to `error` // inside `connect` as that does not work on the edge. // // For more information, see: // // * <https://github.com/connectrpc/connect-es/pull/589> // * <https://github.com/connectrpc/connect-es/issues/749#issuecomment-1693507516> // * <https://github.com/connectrpc/connect-es/pull/1082> // * <https://github.com/e2b-dev/E2B/pull/669/files> // * <https://github.com/connectrpc/connect-es/issues/577#issuecomment-2210103503> function createTransport(baseUrl) { return createConnectTransport({ baseUrl, fetch: fetchProxy, }); } function fetchProxy(input, init) { return fetch(input, { ...init, redirect: "follow" }); } export { createTransport };