cobras-auth-nuxt 1.0.1 → 1.0.2

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": "1.0.0",
7
+ "version": "1.0.1",
8
8
  "builder": {
9
9
  "@nuxt/module-builder": "0.8.4",
10
10
  "unbuild": "unknown"
@@ -1,4 +1,4 @@
1
- import { defineNuxtRouteMiddleware, useRuntimeConfig, useState, navigateTo } from "#imports";
1
+ import { defineNuxtRouteMiddleware, useRuntimeConfig, useState, navigateTo, useRequestURL } from "#imports";
2
2
  export default defineNuxtRouteMiddleware(async (to) => {
3
3
  const config = useRuntimeConfig();
4
4
  const authConfig = config.public.cobrasAuth;
@@ -26,7 +26,8 @@ export default defineNuxtRouteMiddleware(async (to) => {
26
26
  if (typeof window !== "undefined") {
27
27
  redirectUrl = window.location.href;
28
28
  } else {
29
- redirectUrl = to.fullPath;
29
+ const requestUrl = useRequestURL();
30
+ redirectUrl = requestUrl.href;
30
31
  }
31
32
  return navigateTo(
32
33
  `${authConfig.authServiceUrl}/api/auth/authorize?redirect_uri=${encodeURIComponent(redirectUrl)}`,
@@ -1,4 +1,4 @@
1
- import { defineNuxtRouteMiddleware, useRuntimeConfig, useState, navigateTo } from "#imports";
1
+ import { defineNuxtRouteMiddleware, useRuntimeConfig, useState, navigateTo, useRequestURL } from "#imports";
2
2
  export default defineNuxtRouteMiddleware(async (to) => {
3
3
  const config = useRuntimeConfig();
4
4
  const authConfig = config.public.cobrasAuth;
@@ -10,7 +10,13 @@ export default defineNuxtRouteMiddleware(async (to) => {
10
10
  return;
11
11
  }
12
12
  if (!state.value?.user) {
13
- const currentUrl = typeof window !== "undefined" ? window.location.href : to.fullPath;
13
+ let currentUrl;
14
+ if (typeof window !== "undefined") {
15
+ currentUrl = window.location.href;
16
+ } else {
17
+ const requestUrl = useRequestURL();
18
+ currentUrl = requestUrl.href;
19
+ }
14
20
  return navigateTo(
15
21
  `${authConfig.authServiceUrl}/api/auth/authorize?redirect_uri=${encodeURIComponent(currentUrl)}`,
16
22
  { external: true }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "cobras-auth-nuxt",
3
- "version": "1.0.1",
3
+ "version": "1.0.2",
4
4
  "description": "Nuxt 3/4 module for Cobras Auth service - supports internal (SSO) and public modes",
5
5
  "repository": {
6
6
  "type": "git",