Skip to content

Commit 8292d96

Browse files
committed
fix: remove Meteor.absoluteUrl and proxy ddp through vite.
This is needed when using header auth in development, otherwise the websocket to meteor connects directly rather than through the reverse proxy which adds the auth headers. This reverts commit e6e9aa7.
1 parent ddab6df commit 8292d96

File tree

4 files changed

+4
-79
lines changed

4 files changed

+4
-79
lines changed

meteor/__mocks__/meteor.ts

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -195,9 +195,6 @@ export namespace MeteorMock {
195195
// but it'll do for now:
196196
return callAsync(methodName, ...args)
197197
}
198-
export function absoluteUrl(path?: string): string {
199-
return path + '' // todo
200-
}
201198
export function setTimeout(fcn: () => void | Promise<void>, time: number): number {
202199
return $.setTimeout(() => {
203200
Promise.resolve()

packages/webui/src/meteor/meteor.js

Lines changed: 0 additions & 72 deletions
Original file line numberDiff line numberDiff line change
@@ -234,78 +234,6 @@ Meteor.Error.prototype.clone = function () {
234234
return new Meteor.Error(self.error, self.reason, self.details)
235235
}
236236

237-
/**
238-
* @summary Generate an absolute URL pointing to the application. The server reads from the `ROOT_URL` environment variable to determine where it is running. This is taken care of automatically for apps deployed to Galaxy, but must be provided when using `meteor build`.
239-
* @locus Anywhere
240-
* @param {String} [path] A path to append to the root URL. Do not include a leading "`/`".
241-
* @param {Object} [options]
242-
* @param {Boolean} options.secure Create an HTTPS URL.
243-
* @param {Boolean} options.replaceLocalhost Replace localhost with 127.0.0.1. Useful for services that don't recognize localhost as a domain name.
244-
* @param {String} options.rootUrl Override the default ROOT_URL from the server environment. For example: "`http://foo.example.com`"
245-
*/
246-
Meteor.absoluteUrl = function (path, options) {
247-
// path is optional
248-
if (!options && typeof path === 'object') {
249-
options = path
250-
path = undefined
251-
}
252-
// merge options with defaults
253-
options = Object.assign({}, Meteor.absoluteUrl.defaultOptions, options || {})
254-
255-
var url = options.rootUrl
256-
if (!url) throw new Error('Must pass options.rootUrl or set ROOT_URL in the server environment')
257-
258-
if (!/^http[s]?:\/\//i.test(url))
259-
// url starts with 'http://' or 'https://'
260-
url = 'http://' + url // we will later fix to https if options.secure is set
261-
262-
if (!url.endsWith('/')) {
263-
url += '/'
264-
}
265-
266-
if (path) {
267-
// join url and path with a / separator
268-
while (path.startsWith('/')) {
269-
path = path.slice(1)
270-
}
271-
url += path
272-
}
273-
274-
// turn http to https if secure option is set, and we're not talking
275-
// to localhost.
276-
if (
277-
options.secure &&
278-
/^http:/.test(url) && // url starts with 'http:'
279-
!/http:\/\/localhost[:\/]/.test(url) && // doesn't match localhost
280-
!/http:\/\/127\.0\.0\.1[:\/]/.test(url)
281-
)
282-
// or 127.0.0.1
283-
url = url.replace(/^http:/, 'https:')
284-
285-
if (options.replaceLocalhost) url = url.replace(/^http:\/\/localhost([:\/].*)/, 'http://127.0.0.1$1')
286-
287-
return url
288-
}
289-
290-
// allow later packages to override default options
291-
var defaultOptions = (Meteor.absoluteUrl.defaultOptions = {})
292-
293-
// available only in a browser environment
294-
var location = typeof window === 'object' && window.location
295-
296-
if (typeof window.__meteor_runtime_config__ === 'object' && window.__meteor_runtime_config__.ROOT_URL) {
297-
defaultOptions.rootUrl = window.__meteor_runtime_config__.ROOT_URL
298-
} else if (location && location.protocol && location.host) {
299-
defaultOptions.rootUrl = location.protocol + '//' + location.host
300-
}
301-
302-
// Make absolute URLs use HTTPS by default if the current window.location
303-
// uses HTTPS. Since this is just a default, it can be overridden by
304-
// passing { secure: false } if necessary.
305-
if (location && location.protocol === 'https:') {
306-
defaultOptions.secure = true
307-
}
308-
309237
Meteor._relativeToSiteRootUrl = function (link) {
310238
if (typeof window.__meteor_runtime_config__ === 'object' && link.substr(0, 1) === '/')
311239
link = (window.__meteor_runtime_config__.ROOT_URL_PATH_PREFIX || '') + link

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

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -12,10 +12,6 @@ function translateUrl(url, newSchemeBase, subPath) {
1212
newSchemeBase = 'http';
1313
}
1414

15-
if (subPath !== "sockjs" && url.startsWith("/")) {
16-
url = Meteor.absoluteUrl(url.substr(1));
17-
}
18-
1915
var ddpUrlMatch = url.match(/^ddp(i?)\+sockjs:\/\//);
2016
var httpUrlMatch = url.match(/^http(s?):\/\//);
2117
var newScheme;

packages/webui/vite.config.mts

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -59,6 +59,10 @@ export default defineConfig({
5959
'/api': 'http://127.0.0.1:3000',
6060
'/site.webmanifest': 'http://127.0.0.1:3000',
6161
'/meteor-runtime-config.js': 'http://127.0.0.1:3000',
62+
'/websocket': {
63+
target: `ws://127.0.0.1:3000`,
64+
ws: true,
65+
},
6266
},
6367
},
6468

0 commit comments

Comments
 (0)