@egdesk/next-api-plugin 1.5.106 → 1.5.108

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.
@@ -121,6 +121,19 @@ function resolveEgdeskMcpApiUrl(): string {
121
121
  return (process.env.NEXT_PUBLIC_EGDESK_API_URL || 'http://localhost:8080').replace(/\\/$/, '');
122
122
  }
123
123
 
124
+ /**
125
+ * Visitor OAuth state is on the tunnel gateway (Supabase), not desktop in-memory pending.
126
+ */
127
+ function resolveVisitorAuthMcpApiUrl(): string {
128
+ const tunnel = process.env.NEXT_PUBLIC_EGDESK_TUNNEL_URL;
129
+ if (tunnel && tunnel.trim()) return tunnel.replace(/\\/$/, '');
130
+ const publicUrl = process.env.NEXT_PUBLIC_EGDESK_API_URL;
131
+ if (publicUrl && publicUrl.trim()) return publicUrl.replace(/\\/$/, '');
132
+ const internal = process.env.EGDESK_MCP_INTERNAL_URL;
133
+ if (internal && internal.trim()) return internal.replace(/\\/$/, '');
134
+ return 'http://localhost:8080';
135
+ }
136
+
124
137
  export async function middleware(request: NextRequest) {
125
138
  const { pathname } = request.nextUrl;
126
139
 
@@ -446,7 +459,7 @@ export async function middleware(request: NextRequest) {
446
459
  if (pathname.includes('__visitor_auth_proxy')) {
447
460
  try {
448
461
  const body = await request.text();
449
- const apiUrl = resolveEgdeskMcpApiUrl();
462
+ const apiUrl = resolveVisitorAuthMcpApiUrl();
450
463
 
451
464
  const response = await fetch(\`\${apiUrl}/visitor-auth/tools/call\`, {
452
465
  method: 'POST',
@@ -466,7 +479,7 @@ export async function middleware(request: NextRequest) {
466
479
  if (pathname.includes('__visitor_google_proxy')) {
467
480
  try {
468
481
  const body = await request.text();
469
- const apiUrl = resolveEgdeskMcpApiUrl();
482
+ const apiUrl = resolveVisitorAuthMcpApiUrl();
470
483
  const headers = visitorUpstreamHeaders(request);
471
484
  const authorization = request.headers.get('authorization');
472
485
  if (authorization) headers['Authorization'] = authorization;
@@ -100,6 +100,20 @@ function resolveEgdeskMcpApiUrl(): string {
100
100
  return (process.env.NEXT_PUBLIC_EGDESK_API_URL || 'http://localhost:8080').replace(/\\/$/, '');
101
101
  }
102
102
 
103
+ /**
104
+ * Visitor OAuth pending rows and sessions live on the tunnel gateway (Supabase).
105
+ * Do not use EGDESK_MCP_INTERNAL_URL here — desktop :8080 only keeps pending in memory.
106
+ */
107
+ function resolveVisitorAuthMcpApiUrl(): string {
108
+ const tunnel = process.env.NEXT_PUBLIC_EGDESK_TUNNEL_URL;
109
+ if (tunnel && tunnel.trim()) return tunnel.replace(/\\/$/, '');
110
+ const publicUrl = process.env.NEXT_PUBLIC_EGDESK_API_URL;
111
+ if (publicUrl && publicUrl.trim()) return publicUrl.replace(/\\/$/, '');
112
+ const internal = process.env.EGDESK_MCP_INTERNAL_URL;
113
+ if (internal && internal.trim()) return internal.replace(/\\/$/, '');
114
+ return 'http://localhost:8080';
115
+ }
116
+
103
117
  /** Forward this site's origin so EGDesk can bind visitor sessions to this site only. */
104
118
  function visitorForwardHeaders(request: NextRequest): Record<string, string> {
105
119
  const headers = buildEgdeskHeaders();
@@ -800,7 +814,7 @@ export async function proxy(request: NextRequest) {
800
814
  if (pathname.includes('__visitor_auth_proxy')) {
801
815
  try {
802
816
  const body = await request.text();
803
- const apiUrl = resolveEgdeskMcpApiUrl();
817
+ const apiUrl = resolveVisitorAuthMcpApiUrl();
804
818
 
805
819
  const response = await fetch(\`\${apiUrl}/visitor-auth/tools/call\`, {
806
820
  method: 'POST',
@@ -822,7 +836,7 @@ export async function proxy(request: NextRequest) {
822
836
  if (pathname.includes('__visitor_google_proxy')) {
823
837
  try {
824
838
  const body = await request.text();
825
- const apiUrl = resolveEgdeskMcpApiUrl();
839
+ const apiUrl = resolveVisitorAuthMcpApiUrl();
826
840
  const headers = visitorForwardHeaders(request);
827
841
  const authorization = request.headers.get('authorization');
828
842
  if (authorization) headers['Authorization'] = authorization;
package/dist/index.d.ts CHANGED
@@ -8,7 +8,7 @@
8
8
  * The minimum EGDesk app version this plugin version is compatible with.
9
9
  * The app checks this at setup time and warns on mismatch.
10
10
  */
11
- export declare const COMPATIBLE_APP_VERSION = "1.4.111";
11
+ export declare const COMPATIBLE_APP_VERSION = "1.4.113";
12
12
  export interface SetupOptions {
13
13
  egdeskUrl?: string;
14
14
  /** Production EGDesk server URL — written to .env.production.local. Falls back to egdeskUrl. */
package/dist/index.js CHANGED
@@ -46,7 +46,7 @@ exports.setupNextApiPlugin = setupNextApiPlugin;
46
46
  * The minimum EGDesk app version this plugin version is compatible with.
47
47
  * The app checks this at setup time and warns on mismatch.
48
48
  */
49
- exports.COMPATIBLE_APP_VERSION = '1.4.111';
49
+ exports.COMPATIBLE_APP_VERSION = '1.4.113';
50
50
  const fs = __importStar(require("fs"));
51
51
  const path = __importStar(require("path"));
52
52
  const setup_userdata_1 = require("./setup-userdata");
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@egdesk/next-api-plugin",
3
- "version": "1.5.106",
3
+ "version": "1.5.108",
4
4
  "description": "Next.js plugin for EGDesk database proxy integration",
5
5
  "main": "dist/index.js",
6
6
  "types": "dist/index.d.ts",