-
-
Notifications
You must be signed in to change notification settings - Fork 2.3k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
How do I use the middleware on a path other than '/' ? #3098
Comments
I think you can change const parcel_middleware = new Bundler(__dirname+'/../browserclient/src/index.html', {
publicUrl: '/app/',
}).middleware();
app.use('/api', function(req, res, next) {
req.url = req.originalUrl;
parcel_middleware(req, res, next);
}); |
Minimal example: https://github.com/Kogia-sima/express-parcel-example |
But this is confusing. It is better if Parcel use |
The problem with the example solution at github is that it doesn't work at /path, only at /path/. And anyway, isn't this what .publicUrl is for, and this is already supposed to be working out of the box? I.e. isni't this a bug, or am I misunderstanding what .publicUrl is for? |
@mischnic Any chance this can get backported also? As a workaround I have a bunch of extra terminal windows running parcel instances, but it'd be a lot easier if this could all be part of my main server program. |
This issue has been automatically marked as stale because it has not had recent activity. It will be closed in 30 days if no further activity occurs. Thank you for your contributions. |
❔ Question
How can I tell the Bundler middleware to serve out of a subdirectory path?
I'd like to serve a Parcel-bundled app as a subdirectory of an Express app. For production I plan on just pointing Nginx to the
dist/
folder, but for development I'd like to integrate the Parcel middleware into the main server, with hot-reloading etc. I've therefore followed the API docs and attached anew Bundler().middleware()
to the existing Expressapp
, and told theBundler
what its public URL is:Unfortunately, this just serves the index page for everything under /app/, including the JS and CSS bundles. This appears to be because of
parcel/packages/core/parcel-bundler/src/Server.js
Lines 57 to 63 in 0b98eed
options.publicURL
. Unfortunately since I'm usingapp.use(path, ...)
thepathname
variable is relative to /app/ (that is, it goes/index.deadbeef.js
, not/app/index.deadbeef.js
) and so never matches, and the bundled code can never be served. If I just tell it toapp.use(new Bundler())
then it works, but Parcel also takes over the rest of the server and starts handing out its index instead of 404 pages.🌍 Your Environment
The text was updated successfully, but these errors were encountered: