@absolutejs/http

中文文档
0.0.1发布于 2026/08/28BSL-1.1TypeScriptES Module零依赖近 30 天下载 3015

Origin-locked, authentication-aware HTTP transport for AbsoluteJS applications

原始使用文档

@absolutejs/http

Provider-neutral, origin-locked HTTP for AbsoluteJS applications.

import { http } from '@absolutejs/http';

const orders = await http.get<Order[]>('/api/orders');
await http.post('/api/orders', { sku: 'absolute-shirt', quantity: 1 });

Application code stays the same across browser, PWA, and Capacitor builds. The browser transport uses same-origin HTTP-only cookies. AbsoluteJS installs the Capacitor transport with the native Auth client's renewable bearer credential; tokens never enter page code.

Security contract

  • Relative URLs resolve against one configured application origin.
  • Absolute URLs must match that exact origin.
  • HTTPS is required outside loopback development.
  • Application-provided Authorization, Cookie, and Proxy-Authorization headers are rejected. The runtime provider owns credentials.
  • Redirect following is disabled for trusted requests, preventing a server redirect from becoming a credential or request-body forwarding channel.
  • HTTP errors expose status and URL but do not automatically copy a private response body into an exception or diagnostic.

Use http.request() when you need a raw Response, http.text() for text, and http.json() or the method helpers for JSON. @absolutejs/sync remains the durable local-first API; ordinary HTTP is connected-first.

Type parameters describe the decoded result at the call site. For end-to-end route inference, pass http.fetch into the Elysia Eden client used by your application so Eden retains the server route types while AbsoluteJS owns the runtime transport.

Explicit transports

SSR code must install or construct a request-scoped transport rather than guessing a public origin:

import { createAbsoluteHttpClient } from '@absolutejs/http';
import { createSsrHttpTransport } from '@absolutejs/http/ssr';

const http = createAbsoluteHttpClient({
    transport: createSsrHttpTransport({
        origin: 'https://app.example.com'
    })
});

Tests can use createTestHttpTransport() from @absolutejs/http/testing.

版本与发布记录

@absolutejs/http 共发布 1 个版本,首次发布于 2026/08/28;过去 12 个月发布了 1 个版本。

版本发布日期距今
0.0.1latest2026/08/282 个月前

关于 @absolutejs/http 的常见问题

@absolutejs/http 是什么?

Origin-locked, authentication-aware HTTP transport for AbsoluteJS applications

如何安装 @absolutejs/http?

在项目目录运行 npm install @absolutejs/http,或使用 pnpm add / yarn add / bun add。

@absolutejs/http 支持 TypeScript 吗?

支持。包内自带 TypeScript 类型声明(package.json 声明了 types 入口),安装后即可获得类型提示,无需再安装 @types 包。

@absolutejs/http 支持 ESM 还是 CommonJS?

以 ES Module 形式发布,推荐使用 import 引入。在 CommonJS 项目中,Node.js 20.19+ / 22.12+ 可以直接 require() 不含顶层 await 的 ES Module,更早的版本需要改用动态 import()。

@absolutejs/http 可以商用吗?

@absolutejs/http 使用 BSL-1.1 许可。声明的许可为 BSL-1.1,请阅读许可原文确认使用条件。以上为概括,不构成法律意见,请以许可原文为准。

@absolutejs/http 的下载量有多少?

根据 npm 官方下载统计,@absolutejs/http 在 2026/10/05 – 2026/11/03 这 30 天内被下载 3,015 次,日均约 101 次。下载量会把 CI 构建、镜像同步和作为其他包依赖的安装一并计入,适合横向比较热度,不能直接等同于使用人数。

@absolutejs/http 还在维护吗?

最新版本 0.0.1 发布于 2026/08/28(2 个月前);至今共发布 1 个版本,其中过去 12 个月发布了 1 个;首次发布于 2026/08/28。发布频率只是参考信号:功能稳定的工具可能很少需要更新,建议结合源码仓库的 issue 和提交记录判断。