@enfyra/sdk-nuxt 0.7.7 → 0.7.8

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.
package/dist/module.json CHANGED
@@ -4,7 +4,7 @@
4
4
  "compatibility": {
5
5
  "nuxt": ">=3.0.0"
6
6
  },
7
- "version": "0.7.7",
7
+ "version": "0.7.8",
8
8
  "builder": {
9
9
  "@nuxt/module-builder": "0.8.4",
10
10
  "unbuild": "2.0.0"
@@ -1 +1 @@
1
- {"version":3,"file":"auth.d.ts","sourceRoot":"","sources":["../../../../src/runtime/server/middleware/auth.ts"],"names":[],"mappings":";AAQA,wBAsCG"}
1
+ {"version":3,"file":"auth.d.ts","sourceRoot":"","sources":["../../../../src/runtime/server/middleware/auth.ts"],"names":[],"mappings":";AAQA,wBA8CG"}
@@ -6,8 +6,14 @@ import {
6
6
  } from "../../utils/server/refreshToken.js";
7
7
  import { REFRESH_TOKEN_KEY } from "../../constants/auth.js";
8
8
  export default defineEventHandler(async (event) => {
9
+ const config = useRuntimeConfig();
10
+ const apiPrefix = config.public.enfyraSDK?.apiPrefix;
11
+ if (!apiPrefix) return;
9
12
  const url = event.node.req.url || "";
10
- if (url === "/api/login" || url === "/api/logout" || url.startsWith("/api/auth/")) {
13
+ const loginPath = `${apiPrefix}/login`;
14
+ const logoutPath = `${apiPrefix}/logout`;
15
+ const authPrefix = `${apiPrefix}/auth/`;
16
+ if (url === loginPath || url === logoutPath || url.startsWith(authPrefix)) {
11
17
  return;
12
18
  }
13
19
  const { accessToken, needsRefresh } = validateTokens(event);
@@ -16,8 +22,8 @@ export default defineEventHandler(async (event) => {
16
22
  const refreshToken = getCookie(event, REFRESH_TOKEN_KEY);
17
23
  if (refreshToken) {
18
24
  try {
19
- const config = useRuntimeConfig();
20
- const apiUrl = config.public?.enfyraSDK?.apiUrl;
25
+ const config2 = useRuntimeConfig();
26
+ const apiUrl = config2.public?.enfyraSDK?.apiUrl;
21
27
  if (apiUrl) {
22
28
  currentAccessToken = await refreshAccessToken(
23
29
  event,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@enfyra/sdk-nuxt",
3
- "version": "0.7.7",
3
+ "version": "0.7.8",
4
4
  "type": "module",
5
5
  "description": "Nuxt SDK for Enfyra CMS",
6
6
  "repository": {
@@ -7,12 +7,20 @@ import {
7
7
  import { REFRESH_TOKEN_KEY } from "../../constants/auth";
8
8
 
9
9
  export default defineEventHandler(async (event) => {
10
+ const config = useRuntimeConfig();
11
+ const apiPrefix = config.public.enfyraSDK?.apiPrefix;
12
+ if (!apiPrefix) return;
13
+
10
14
  const url = event.node.req.url || "";
11
15
 
16
+ const loginPath = `${apiPrefix}/login`;
17
+ const logoutPath = `${apiPrefix}/logout`;
18
+ const authPrefix = `${apiPrefix}/auth/`;
19
+
12
20
  if (
13
- url === "/api/login" ||
14
- url === "/api/logout" ||
15
- url.startsWith("/api/auth/")
21
+ url === loginPath ||
22
+ url === logoutPath ||
23
+ url.startsWith(authPrefix)
16
24
  ) {
17
25
  return;
18
26
  }