Commit Graph

302 Commits

Author SHA1 Message Date
Ben Newman
62388fb7c4 Unify web.* arch resolution in WebApp.categorizeRequest.
https://github.com/meteor/meteor/pull/10994#issuecomment-606270894
2020-03-31 12:07:23 -04:00
Ben Newman
d27d0a279d Try other web.* arches if preferred arch was excluded.
Follow-up to #10824.

If the preferred arch is not available (most likely because it was
deliberately excluded), it's better to use another client arch that is
available than to guarantee the site won't work by returning an unknown
arch. For example, if web.browser.legacy is excluded using the
--exclude-archs option (introduced by #10824), legacy clients are better
served by receiving web.browser (which might actually work) than receiving
an HTTP 404 response. If none of the arches in preferredArchOrder are
defined, only then should we send a 404.
2020-03-31 12:07:23 -04:00
Ben Newman
70d25386af Merge branch 'devel' into release-1.10 2020-02-25 19:40:53 -05:00
Seba Kerckhof
163881163f Don't lose the query string when using a path prefix (#10845)
Fixes https://github.com/meteor/meteor/issues/10756
2020-02-25 19:31:42 -05:00
Ben Newman
8ff7eed55c Merge branch 'devel' into release-1.10 2020-02-19 09:41:44 -05:00
Ben Newman
8c022eaced Restore webapp changes that were intended for Meteor 1.10.
Revert "Bump webapp version to 1.8.2, with same content as 1.8.0."
This reverts commit 20d2a9b4a4.

Revert "Revert changes to webapp package since version 1.8.0."
This reverts commit 7a6ee9e129.
2020-01-16 11:26:54 -05:00
Ben Newman
7a6ee9e129 Revert changes to webapp package since version 1.8.0.
We accidentally published changes to webapp that should have been
restricted to Meteor 1.10 as part of the 1.8.1 version. This commit
reverts commits to packages/webapp since Meteor 1.9, so that we can
republish the 1.8.0 content as version 1.8.2. We will then bump the webapp
version to 1.9.0 on the release-1.10 branch and publish the new content
only on that branch.

Revert "Allow to exclude web architectures in development mode (#10824)"
This reverts commit a205967186.

Revert "Updates cordova-plugin-meteor-webapp to 1.7.1"
This reverts commit a1e4d27822.

Revert "Update cordova-plugin-wkwebview-engine to 1.2.1."
This reverts commit 3f9a69d7c4.

Revert "Update cordova-plugin-whitelist to 1.3.4."
This reverts commit 979273333b.

Revert "Update cordova-plugin-meteor-webapp to 1.7.1-beta.1."
This reverts commit 565c4254f1.

Revert "Update accounts-password to version 1.5.2."
This reverts commit b827d1da2f.
2020-01-16 11:15:25 -05:00
Seba Kerckhof
a205967186 Allow to exclude web architectures in development mode (#10824) 2020-01-13 16:24:50 -05:00
seke
80892e5965 Add hash to runtime config file url
Although Meteor doesn't send cache headers to the runtime config file, a reverse proxy might still cache it.
Some reverse proxies will treat this case similar to cache-control: private.
So adding the hash can prevent reverse proxies from serving stale versions.
Furthermore, by adding the hash, it can actually be cached correctly by reverse proxies.

For more context: https://github.com/meteor/meteor/issues/10733
2020-01-13 15:23:23 +01:00
Florian Kaiser
11ef927252 Remove qs-middleware from webapp package to avoid license issues (#10711)
Closes #10707.
2019-10-24 18:33:34 -04:00
Ben Newman
05e5cb9105 Avoid global staticFilesByArch variable in webapp_server.js. 2019-02-28 13:50:08 -05:00
Ben Newman
a89b34c4c2 Remove hash of minimum modern browser versions from client hash.
This partially reverts commit 99b79dc00f,
which was added as part of PR #10055 in an effort to trigger hot reloads
on the client when/if the definition of a "modern" browser happened to
change, due to server code calling setMinimumBrowserVersions. Although
changes in the minimum modern browser versions are pretty rare, it seemed
important to incorporate this information into the client hash, because
code sent to the client tends to be dramatically different depending on
whether the client is considered modern.

However, this change was made without updating the corresponding version
calculations in CordovaBuilder#appendVersion in tools/cordova/builder.js,
so the versions in program.json for Cordova apps disagreed with the
versions served in manifest.json by the web server, leading to the
problems described by @lorensr in this cordova-plugin-meteor-webapp issue:
https://github.com/meteor/cordova-plugin-meteor-webapp/issues/69

It would be nice to include the minimum versions hash in program.json for
Cordova builds, but unfortunately these versions are not known at build
time, because they are determined by calls to setMinimumBrowserVersions
during server startup. In other words, if we wanted to access that
information during Cordova builds, we would have to start the web server
and run all server-side application initialization code just to find out
if setMinimumBrowserVersions was called anywhere.

In the future, we could consider including the minimum versions hash in
manifest.json, so cordova-plugin-meteor-webapp could compare the current
version to the new version whenever it fetches manifest.json. However, I
think simply removing the minimum versions hash from the client version
calculation is a fine solution in the meantime. If a developer needs to
trigger a hot reload because they changed their minimum modern versions,
they should just be sure to change their client code at the same time.
Any change that would normally trigger a client reload will work.
2019-01-14 20:41:16 -05:00
georgyberdyshev
5d43d2c2b2 Selectively disable compression based on the incoming request (#10378)
Setting the x-no-compression request header disables compression.

Closes #10377.
2019-01-11 17:08:53 -05:00
Ben Newman
40ac2de412 Use object ...spread syntax rather than _.extend. 2018-11-21 11:34:01 -05:00
Nathan Muir
2e428c8ef3 webapp: add runtime config overrides when inline scripts are disabled
When generating boilerplate, meteor runtime config includes additional
options based on the arch.

However, these additional options were not present when generating
the response to `/meteor_runtime_config.js`, which is used when
inline scripts are disabled.

This change fixes Meteor.isModern in those circumstances.
2018-10-30 17:41:47 +10:00
Geoffrey Challen
8dd3ce5028 Parse URL query parameters before it's destroyed (#10152)
The inline middleware that strips the ROOT_URL_PATH_PREFIX destroys req.url. If this happens before the query parameters are parsed by use(query()) the query parameters are always missing. This causes OAuth authentication to fail when ROOT_URL_PATH_PREFIX is set.

A better fix would be to fix the path stripping logic so that it preserves the URL parameters, since other things may try to rely on them later. But this works for now.
2018-08-14 15:25:55 -04:00
Ben Newman
cfb6a45ab5 Compute static manifest.json lazily in webapp_server.js.
Should fix #10088.
2018-08-13 18:43:24 -04:00
Ben Newman
60c670f0b3 Move AUTOUPDATE_VERSION logic out of webapp_server.js.
It seems obvious in hindsight, but any logic relating to the
AUTOUPDATE_VERSION override should reside within the autoupdate package,
and the true client hashes should be available to any other package that
needs them, without AUTOUPDATE_VERSION getting in the way.
2018-07-19 14:04:32 -04:00
Ben Newman
77ed148614 Use listener API for communication between build/server processes.
Fixes #10073, per
https://github.com/meteor/meteor/issues/10073#issuecomment-405290391

While thinking about this bug, I realized that sending IPC messages to
specific packages in the server process was much less flexible than
sending messages based on an arbitrary topic string, since the topic
string approach allows both `autoupdate` and `dynamic-import` to listen
for the same message.

The topic string approach calls for a listener interface like
`onMessage(topic, callback)`, which elegantly replaces the previous
approach of requiring packages to export a single `onMessage` function.

However, because the `meteor` package does not have access to the module
system, implementing the `onMessage` listener interface in the `meteor`
package would have required exposing an API like `Meteor.onMessage(topic,
callback)`, which has an unpleasant global smell to it. Instead, the
`onMessage` function should be explicitly imported (using the module
system) from a less-generically-named package.

Since I knew I was going to have to move the message dispatch logic out of
the `meteor` package, I decided to create a new package called
`inter-process-messaging` to implement the parent/child components of the
IPC system.
2018-07-16 18:59:50 -04:00
Ben Newman
1387473cf5 Pause requests for the legacy bundle while rewriting it.
This is the solution I came up with for the problems I described here:
https://github.com/meteor/meteor/pull/10055#issuecomment-403219805
2018-07-10 21:17:14 -04:00
Ben Newman
4b17a0b760 Allow sending IPC messages from build process to server process.
Instead of having every message consumer listen to every message and act
on the ones that seem relevant to its interests, we now have a single
process.on("message", callback) hook that can dispatch messages to
different Meteor packages running in the server process.

Receiving packages should export an onMessage function. The onMessage
function may be async, and its result will be delivered back to the build
process as the result of the sendMessage Promise.
2018-07-10 21:17:14 -04:00
Ben Newman
99b79dc00f Include hash of minimum modern versions in autoupdate versions. 2018-07-10 17:43:28 -04:00
Ben Newman
fe9e4035f9 Rewrite autoupdate to distinguish versions by client architecture.
Now that we're postponing the legacy build until after the first client
refresh message is sent, there's a risk that changes to the legacy build
will not be picked up until after the next rebuild.

If we attempted to fix that problem by sending the refresh message after
the legacy bundle is rebuilt, then we would lose most of the benefit of
delaying the legacy build, because the client would not refresh until
after the legacy build completed.

The right way to fix the problem is by sending a second client refresh
message after the legacy build finishes, but doing so with the current
autoupdate implementation would very likely cause modern clients to reload
a second time.

The solution implemented by this commit is simple in theory: the
autoupdate package should keep track of distinct versions for each client
architecture, so that modern clients will refresh only when the modern
versions change, and legacy clients will refresh only when the legacy
versions change, which allows us to send two refresh messages without
causing any clients to refresh more than once.

In reality, this was a fairly major rewrite, since the ClientVersions
collection has a totally different schema now. I've tested it as well as I
can, though I'm not entirely sure what will happen if clients using the
previous version of the autoupdate package begin receiving DDP messages
from this version of the autoupdate server code.
2018-07-06 19:58:57 -04:00
Ben Newman
e3082a43f6 Precompute WebApp.* client hashes in generateClientProgram.
This means the autoupdate package is no longer responsible for recomputing
client hashes, and we can recompute the hashes whenever there's a new (or
updated) client program, which enables delayed builds of architectures
like web.browser.legacy (#10055).
2018-07-06 13:32:49 -04:00
Ben Newman
ae2ebda6af Start webapp server after WebAppInternals.* fully populated. 2018-07-06 13:32:48 -04:00
Ben Newman
265d9e30d4 Reload legacy bundle using a syncQueue.runTask callback. 2018-07-05 11:20:50 -04:00
Ben Newman
aade180d46 Build web.browser.legacy bundle after startup on rebuilds. 2018-07-04 12:26:23 -04:00
Ben Newman
c914df087e Extract generateClientProgram from WebAppInternals.reloadClientPrograms. 2018-07-04 10:15:28 -04:00
Timo Horstschaefer
ef3af685ab Enable Sub-Resource Integrity hashes for JS and CSS files (#9933) 2018-07-03 12:30:22 -04:00
Ben Newman
d291dffbb3 Fix ROOT_URL path prefix stripping in webapp_server.js. (#10040)
Thanks to @Zodiase for doing most of the investigation here:
https://github.com/meteor/meteor/issues/10019#issuecomment-401225148

Fixes #10019.
2018-06-29 12:22:03 -04:00
Ben Newman
0a336175c4 Let any client request any static resource. (#9965)
Fixes #9953.
2018-06-07 16:20:38 -04:00
Ben Newman
182c426c6d Set Vary:User-Agent response header for static files.
The only new functionality is the res.setHeader("Vary", "User-Agent")
call; the rest of the changes in this commit are just reformatting.

@CaptainN I think this should be enough information for well-behaved
browsers and CDNs to do the right thing, though I agree it's worth
documenting.
2018-04-30 19:47:12 -04:00
Ben Newman
223ec46525 Use isModern(request.browser) to determine architecture of static files.
Note that WebAppInternals.staticFiles has been replaced by
WebAppInternals.staticFilesByArch.
2018-04-29 09:58:08 -04:00
Ben Newman
b50a52ecf5 Tolerate assets added with same path to both modern and legacy architectures.
Since legacy assets are no longer disambiguated from modern assets with a
/__browser.legacy/ URL prefix (#9776), we need a principled way to handle
collisions in the staticFiles registry.
2018-04-27 12:41:36 -04:00
David Glasser
e5a4306b63 webapp: allow overriding httpServer.listen (#9720) 2018-03-07 12:04:54 -05:00
Ben Newman
bfbb8baf5f Add "/__arch" prefixes to URLs in tools/isobuild/bundler.js.
This avoids the need to add architecture-specific prefixes in
webapp_server.js, and also fixes dynamic module source map URLs.
2018-01-22 18:07:53 -05:00
Ben Newman
8f921a4b87 Prepend prefix to all static URLs, even for WebApp.defaultArch. 2018-01-22 17:54:43 -05:00
Ben Newman
f3053e253a Add architecture prefix to static resource URLs in boilerplate. 2018-01-22 17:54:43 -05:00
Ben Newman
6c5c386c4a Allow serving CSS for all client architectures. 2018-01-22 17:54:43 -05:00
Ben Newman
911dae81bb Expose Meteor.isModern on both client and server. 2018-01-22 17:54:43 -05:00
Ben Newman
e18ef9eb0e Use isModern in webapp to determine which boilerplate to generate.
Surely it can't be this easy, can it?
2018-01-22 17:54:42 -05:00
Ben Newman
ed28140071 Support a new web.browser.legacy platform. 2018-01-22 17:54:42 -05:00
Ben Newman
d0db2571e4 Guarantee all WebApp handler functions run in a Fiber.
https://github.com/VeliovGroup/Meteor-Files/issues/538
2018-01-16 16:58:57 -05:00
Ben Newman
fbdacbf560 Preserve /__cordova/manifest.json URLs, to fix #9526. 2018-01-14 16:32:47 -05:00
Ben Newman
991fb5ea86 Rename Boilerplate#toHTML to toHTMLStream and deprecate toHTML.
PR #9343 changed the return type of Boilerplate#toHTML from String to
Stream, which is likely to break existing code that expects a string.

In order to make the change in return type more obvious, I have renamed
the method to toHTMLStream, and I have attempted to update all call sites
appropriately. However, because this change comes in the release candidate
phase of Meteor 1.6.1 testing, it seemed important to preserve the
string-returning behavior of toHTML, with a deprecation notice.

Unless third-party code is using the Boilerplate class directly, I don't
think the toHTML method will ever be called, and we can remove it in
Meteor 1.6.2.

Thanks to @macrozone for tracking this problem down.

Fixes #9521.
2018-01-09 12:12:11 -05:00
Ben Newman
9a391d9b04 Fix #9428 by registering dynamic-import HTTP endpoint earlier. (#9465) 2017-12-12 17:27:41 -05:00
Hugh Willson
93fe8f13a4 Stop serving the application manifest from /manifest.json (#9424)
* Stop serving the application manifest from /manifest.json

Meteor currently serves its own manifest file from
`/manifest.json`. This location is not application
configurable, and can conflict with other non-Meteor
defined manifest files, that are already being served
from this location. There isn't really any reason why
Meteor needs to use the `/manifest.json` location, so
this commit moves it to `/__meteor__/webapp/manifest.json`.

Fixes #6674.

* Add PR link to History.md
2017-12-01 18:28:15 -05:00
Ben Newman
8dbd41719a End HTTP response when stream ends. 2017-11-22 20:09:18 -05:00
James Baxley
d17683eb98 remove memoization of requests 2017-11-22 20:09:18 -05:00
James Baxley
7ef237f99c refactored to a single stream api 2017-11-22 20:09:18 -05:00