UNPKG

@arcjet/transport

Version:

Transport mechanisms for the Arcjet protocol

30 lines (27 loc) 1.03 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> function createTransport(baseUrl) { return createConnectTransport({ baseUrl, interceptors: [ (next) => (req) => { req.init.redirect = "follow"; return next(req); }, ], fetch, }); } export { createTransport };