Skip to content
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

Fix missing hostWhitelist in FastBoot's package.json manifest #574

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions packages/compat/src/compat-adapters/ember-cli-fastboot.ts
Original file line number Diff line number Diff line change
Expand Up @@ -119,6 +119,7 @@ class RewriteManifest extends Plugin {
schemaVersion: 5,
htmlEntrypoint: 'index.html',
moduleWhitelist: json.fastboot.moduleWhitelist,
hostWhitelist: json.fastboot.hostWhitelist,
};

// this is a message to Embroider stage2 (in app.ts), because we need it to
Expand Down
14 changes: 14 additions & 0 deletions test-packages/fastboot-app/app/routes/index.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
import Route from '@ember/routing/route';
import { inject as service } from '@ember/service';

export default class IndexRoute extends Route {
@service
fastboot;

beforeModel() {
// This is only to to make sure we can correctly access the request's host, which fails if FastBoot's `hostWhitelist`
// is not correctly set up. This is the case when the changes added to /dist/package.json by FastBoot are not correctly
// merged by Embroider. So this serves as a reproduction of https://github.com/embroider-build/embroider/issues/160
return this.fastboot.isFastBoot ? this.fastboot.request.host : null;
}
}
11 changes: 7 additions & 4 deletions test-packages/fastboot-app/config/environment.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
'use strict';

module.exports = function(environment) {
module.exports = function (environment) {
let ENV = {
modulePrefix: 'fastboot-app',
environment,
Expand All @@ -13,14 +13,17 @@ module.exports = function(environment) {
},
EXTEND_PROTOTYPES: {
// Prevent Ember Data from overriding Date.parse.
Date: false
}
Date: false,
},
},
fastboot: {
hostWhitelist: [/^localhost:\d+$/],
},

APP: {
// Here you can pass flags/options to your application instance
// when it is created
}
},
};

if (environment === 'development') {
Expand Down