request.d.ts 1.5 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950
  1. import type { I18NConfig } from '../../config-shared';
  2. import type { RequestData } from '../types';
  3. import { NextURL } from '../next-url';
  4. import { NextCookies } from './cookies';
  5. export declare const INTERNALS: unique symbol;
  6. export declare class NextRequest extends Request {
  7. [INTERNALS]: {
  8. cookies: NextCookies;
  9. geo: RequestData['geo'];
  10. ip?: string;
  11. url: NextURL;
  12. };
  13. constructor(input: URL | RequestInfo, init?: RequestInit);
  14. get cookies(): NextCookies;
  15. get geo(): {
  16. city?: string | undefined;
  17. country?: string | undefined;
  18. region?: string | undefined;
  19. latitude?: string | undefined;
  20. longitude?: string | undefined;
  21. } | undefined;
  22. get ip(): string | undefined;
  23. get nextUrl(): NextURL;
  24. /**
  25. * @deprecated
  26. * `page` has been deprecated in favour of `URLPattern`.
  27. * Read more: https://nextjs.org/docs/messages/middleware-request-page
  28. */
  29. get page(): void;
  30. /**
  31. * @deprecated
  32. * `ua` has been removed in favour of \`userAgent\` function.
  33. * Read more: https://nextjs.org/docs/messages/middleware-parse-user-agent
  34. */
  35. get ua(): void;
  36. get url(): string;
  37. }
  38. export interface RequestInit extends globalThis.RequestInit {
  39. geo?: {
  40. city?: string;
  41. country?: string;
  42. region?: string;
  43. };
  44. ip?: string;
  45. nextConfig?: {
  46. basePath?: string;
  47. i18n?: I18NConfig | null;
  48. trailingSlash?: boolean;
  49. };
  50. }