@tthr/vue 0.0.28 → 0.0.29
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/nuxt/module.ts +13 -2
- package/nuxt/runtime/plugin.client.ts +15 -3
- package/package.json +1 -1
package/nuxt/module.ts
CHANGED
|
@@ -43,12 +43,20 @@ export default defineNuxtModule<TetherModuleOptions>({
|
|
|
43
43
|
setup(options, nuxt) {
|
|
44
44
|
const resolver = createResolver(import.meta.url);
|
|
45
45
|
|
|
46
|
-
//
|
|
46
|
+
// Get values from options or env vars (build-time defaults)
|
|
47
|
+
// These can be overridden at runtime via NUXT_TETHER_* and NUXT_PUBLIC_TETHER_* env vars
|
|
47
48
|
const apiKey = process.env.TETHER_API_KEY || '';
|
|
48
49
|
const url = options.url || process.env.TETHER_URL || 'https://tether-api.strands.gg';
|
|
49
50
|
const projectId = options.projectId || process.env.TETHER_PROJECT_ID || '';
|
|
50
51
|
|
|
52
|
+
// Calculate WebSocket URL from HTTP URL
|
|
53
|
+
const wsUrl = url.replace(/^https:/, 'wss:').replace(/^http:/, 'ws:');
|
|
54
|
+
|
|
51
55
|
// Server-side config (includes API key - never exposed to client)
|
|
56
|
+
// Can be overridden at runtime via:
|
|
57
|
+
// - NUXT_TETHER_API_KEY
|
|
58
|
+
// - NUXT_TETHER_URL
|
|
59
|
+
// - NUXT_TETHER_PROJECT_ID
|
|
52
60
|
nuxt.options.runtimeConfig.tether = {
|
|
53
61
|
apiKey,
|
|
54
62
|
url,
|
|
@@ -56,9 +64,12 @@ export default defineNuxtModule<TetherModuleOptions>({
|
|
|
56
64
|
};
|
|
57
65
|
|
|
58
66
|
// Public config (safe for client - no secrets)
|
|
67
|
+
// Can be overridden at runtime via:
|
|
68
|
+
// - NUXT_PUBLIC_TETHER_PROJECT_ID
|
|
69
|
+
// - NUXT_PUBLIC_TETHER_WS_URL
|
|
59
70
|
nuxt.options.runtimeConfig.public.tether = {
|
|
60
71
|
projectId,
|
|
61
|
-
wsUrl
|
|
72
|
+
wsUrl,
|
|
62
73
|
};
|
|
63
74
|
|
|
64
75
|
// Add server API routes for proxying Tether requests
|
|
@@ -21,8 +21,20 @@ export default defineNuxtPlugin(() => {
|
|
|
21
21
|
|
|
22
22
|
// Make config available for WebSocket connections
|
|
23
23
|
// This is safe - no secrets are exposed
|
|
24
|
-
|
|
25
|
-
projectId: config.public.tether
|
|
26
|
-
wsUrl: config.public.tether
|
|
24
|
+
const tetherConfig = {
|
|
25
|
+
projectId: config.public.tether?.projectId || '',
|
|
26
|
+
wsUrl: config.public.tether?.wsUrl || '',
|
|
27
27
|
};
|
|
28
|
+
|
|
29
|
+
window.__TETHER_CONFIG__ = tetherConfig;
|
|
30
|
+
|
|
31
|
+
// Debug logging
|
|
32
|
+
console.log('[Tether] Client plugin loaded with config:', {
|
|
33
|
+
projectId: tetherConfig.projectId ? `${tetherConfig.projectId.slice(0, 8)}...` : '(empty)',
|
|
34
|
+
wsUrl: tetherConfig.wsUrl || '(empty)',
|
|
35
|
+
});
|
|
36
|
+
|
|
37
|
+
if (!tetherConfig.wsUrl || !tetherConfig.projectId) {
|
|
38
|
+
console.warn('[Tether] Config incomplete - WebSocket subscriptions will not work');
|
|
39
|
+
}
|
|
28
40
|
});
|