Dev Build / cleanup (push) Canceled after 0s
Dev Build / typecheck (push) Canceled after 0s
Dev Build / build (linux-arm64, ubuntu-24.04-arm, linux-arm64) (push) Canceled after 0s
Dev Build / build (linux-x64, ubuntu-latest, linux-x64) (push) Canceled after 0s
Dev Build / build (win-x64, windows-latest, win32-x64) (push) Canceled after 0s
Dev Build / dispatch-dev-docker (push) Canceled after 0s
25 lines
757 B
Plaintext
25 lines
757 B
Plaintext
//#region src/adapter/cloudflare-pages/conninfo.ts
|
|
/**
|
|
* Get connection information from Cloudflare Pages
|
|
* @param c - Context
|
|
* @returns Connection information including remote address
|
|
* @example
|
|
* ```ts
|
|
* import { Hono } from 'hono'
|
|
* import { handle, getConnInfo } from 'hono/cloudflare-pages'
|
|
*
|
|
* const app = new Hono()
|
|
*
|
|
* app.get('/', (c) => {
|
|
* const info = getConnInfo(c)
|
|
* return c.text(`Your IP: ${info.remote.address}`)
|
|
* })
|
|
*
|
|
* export const onRequest = handle(app)
|
|
* ```
|
|
* @deprecated `hono/cloudflare-pages` will be removed in v5. Cloudflare recommends Workers with static assets; use `hono` on Workers instead.
|
|
*/
|
|
const getConnInfo = (c) => ({ remote: { address: c.req.header("cf-connecting-ip") } });
|
|
//#endregion
|
|
export { getConnInfo };
|