Skip to content

Commit ea4bbdc

Browse files
committed
feat: allow webui to use custom ddp path
1 parent cfc6201 commit ea4bbdc

5 files changed

Lines changed: 12 additions & 37 deletions

File tree

packages/webui/src/client/collections/lib.ts

Lines changed: 0 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -69,22 +69,6 @@ export function getOrCreateMongoCollection(name: string): Mongo.Collection<any>
6969
return newCollection
7070
}
7171

72-
/**
73-
* Wrap an existing Mongo.Collection to have async methods. Primarily to convert the built-in Users collection
74-
* @param collection Collection to wrap
75-
* @param name Name of the collection
76-
*/
77-
export function wrapMongoCollection<DBInterface extends { _id: ProtectedString<any> }>(
78-
collection: Mongo.Collection<DBInterface>,
79-
name: CollectionName
80-
): MongoCollection<DBInterface> {
81-
const wrapped = new WrappedMongoCollection<DBInterface>(collection, name)
82-
83-
registerClientCollection(name, wrapped)
84-
85-
return wrapped
86-
}
87-
8872
/**
8973
* Create a sync in-memory Mongo Collection (for ui temporary storage)
9074
* @param name Name of the collection (for logging)

packages/webui/src/meteor/ddp/client_convenience.js

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,9 @@ import { Meteor } from '../meteor'
1818
// stream_client_common.js #RationalizingRelativeDDPURLs
1919
const runtimeConfig =
2020
typeof window.__meteor_runtime_config__ !== 'undefined' ? window.__meteor_runtime_config__ : Object.create(null)
21-
const ddpUrl = runtimeConfig.DDP_DEFAULT_CONNECTION_URL || '/'
21+
// The backend injects DDP_DEFAULT_CONNECTION_URL as the full endpoint path (the client no longer
22+
// appends `/websocket` — see socket-stream-client/urls.js). Fall back to the Meteor default endpoint.
23+
const ddpUrl = runtimeConfig.DDP_DEFAULT_CONNECTION_URL || '/websocket'
2224

2325
Meteor.connection = DDP.connect(ddpUrl)
2426

packages/webui/src/meteor/meteor.d.ts

Lines changed: 0 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -165,18 +165,6 @@ export namespace Meteor {
165165
}
166166
/** Pub/Sub **/
167167

168-
/** Login **/
169-
170-
function loginWithPassword(
171-
user: Object | string,
172-
password: string,
173-
callback?: (error?: global_Error | Meteor.Error | Meteor.TypedError) => void
174-
): void
175-
176-
function logout(callback?: (error?: global_Error | Meteor.Error | Meteor.TypedError) => void): void
177-
178-
/** Login **/
179-
180168
/** Connection **/
181169
function reconnect(): void
182170

packages/webui/src/meteor/socket-stream-client/urls.js

Lines changed: 5 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -3,11 +3,9 @@ import { Meteor } from '../meteor'
33
// @param url {String} URL to Meteor app, eg:
44
// "/" or "madewith.meteor.com" or "https://foo.meteor.com"
55
// or "ddp+sockjs://ddp--****-foo.meteor.com/sockjs"
6-
// @returns {String} URL to the endpoint with the specific scheme and subPath, e.g.
7-
// for scheme "http" and subPath "sockjs"
8-
// "http://subdomain.meteor.com/sockjs" or "/sockjs"
9-
// or "https://ddp--1234-foo.meteor.com/sockjs"
10-
function translateUrl(url, newSchemeBase, subPath) {
6+
// @returns {String} URL to the endpoint with the given scheme, e.g. for scheme "ws"
7+
// "ws://subdomain.meteor.com/websocket" or "/websocket"
8+
function translateUrl(url, newSchemeBase) {
119
if (!newSchemeBase) {
1210
newSchemeBase = 'http'
1311
}
@@ -52,10 +50,9 @@ function translateUrl(url, newSchemeBase, subPath) {
5250
// root. See also client_convenience.js #RationalizingRelativeDDPURLs
5351
url = Meteor._relativeToSiteRootUrl(url)
5452

55-
if (url.endsWith('/')) return url + subPath
56-
else return url + '/' + subPath
53+
return url
5754
}
5855

5956
export function toWebsocketUrl(url) {
60-
return translateUrl(url, 'ws', 'websocket')
57+
return translateUrl(url, 'ws')
6158
}

packages/webui/vite.config.mts

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -85,6 +85,10 @@ export default defineConfig(({ command }) => ({
8585
target: `ws://127.0.0.1:3000`,
8686
ws: true,
8787
},
88+
[basePath + '/ddp-next/websocket']: {
89+
target: `ws://127.0.0.1:3000`,
90+
ws: true,
91+
},
8892
},
8993
},
9094

0 commit comments

Comments
 (0)