@easy-cms/nuxt 0.47.3 → 0.48.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -3,7 +3,7 @@ import { Config } from '@easy-cms/core';
3
3
 
4
4
  interface HandlerOptions {
5
5
  readonly basePath: string;
6
- /** Trust `X-Forwarded-For` for the client IP (only behind a proxy you control). */
6
+ /** The client IP from `X-Forwarded-For`, its last entry (only behind a proxy you control). */
7
7
  readonly trustProxy: boolean;
8
8
  }
9
9
  /** Mounts the Easy CMS REST API as a Nitro event handler. */
@@ -1,5 +1,11 @@
1
- import { createApiHandler } from "@easy-cms/core";
2
- import { defineEventHandler, getRequestIP, sendWebResponse, toWebRequest } from "h3";
1
+ import { createApiHandler, forwardedClientIp, platformClientIp } from "@easy-cms/core";
2
+ import {
3
+ defineEventHandler,
4
+ getRequestHeader,
5
+ getRequestIP,
6
+ sendWebResponse,
7
+ toWebRequest
8
+ } from "h3";
3
9
  function createHandler(config, options) {
4
10
  const clientIps = /* @__PURE__ */ new WeakMap();
5
11
  const api = createApiHandler(config, {
@@ -8,7 +14,10 @@ function createHandler(config, options) {
8
14
  });
9
15
  return defineEventHandler(async (event) => {
10
16
  const request = toWebRequest(event);
11
- clientIps.set(request, getRequestIP(event, { xForwardedFor: options.trustProxy }));
17
+ clientIps.set(
18
+ request,
19
+ options.trustProxy ? forwardedClientIp(getRequestHeader(event, "x-forwarded-for")) : platformClientIp(request.headers) ?? getRequestIP(event)
20
+ );
12
21
  return sendWebResponse(event, await api(request));
13
22
  });
14
23
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@easy-cms/nuxt",
3
- "version": "0.47.3",
3
+ "version": "0.48.0",
4
4
  "description": "Nuxt module for Easy CMS",
5
5
  "license": "MIT",
6
6
  "type": "module",
@@ -20,19 +20,19 @@
20
20
  "dependencies": {
21
21
  "@nuxt/kit": "^4.5.2",
22
22
  "h3": "^1.15.11",
23
- "@easy-cms/admin": "^0.47.3"
23
+ "@easy-cms/admin": "^0.48.0"
24
24
  },
25
25
  "peerDependencies": {
26
26
  "nuxt": "^4.0.0",
27
- "@easy-cms/core": "^0.47.3"
27
+ "@easy-cms/core": "^0.48.0"
28
28
  },
29
29
  "devDependencies": {
30
30
  "@nuxt/schema": "^4.5.2",
31
31
  "@nuxt/test-utils": "^4.3.2",
32
32
  "nuxt": "^4.5.2",
33
33
  "vue": "^3.5.0",
34
- "@easy-cms/core": "^0.47.3",
35
- "@easy-cms/db-sqlite": "^0.47.3"
34
+ "@easy-cms/core": "^0.48.0",
35
+ "@easy-cms/db-sqlite": "^0.48.0"
36
36
  },
37
37
  "publishConfig": {
38
38
  "access": "public"