-
Notifications
You must be signed in to change notification settings - Fork 215
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
Enable enhanced customization of server options #292
base: master
Are you sure you want to change the base?
Conversation
@joliss: Any feedback? |
@joliss @jakedetels When do you merge this feature? I need this feature for adding custom headers to server response. Thank you |
@jakedetels / @oksuz sorry for the long delay in response. I believe in broad-strokes I agree with this approach. The code-base has changed some, if you are still using broccoli and would like to rebase and update the code. I would love to revisit this, and help get it in. |
@stefanpenner: I'll aim to get this PR updated by the end of the month (12/31/2017). If needed sooner, let me know. |
Friendly ping 🏂 |
Faced the issue today, this PR would be very helpful 😊 |
I like idea about additional customization, but I think having multiple ways to do it - not an optimal direction. We could have // module.exports = async function({env, mode} : { env: 'prod' | 'dev'; mode: 'build' | 'serve' }) {
return {
port: 4011,
host: '192.168.1.1',
staticHeaders: {
'Access-Control-Alow-Origin': '*'
},
middleware: {
onError(req, resp, error) {
//tbd
},
onRequest(req, resp, next) {
//tbd
},
postRequest(req, resp) {
//tbd
}
}
}
} |
This pull request aims to enhance the user's ability to customize the options passed to
broccoli.server.serve()
in a couple different ways.First, users can customize the http response headers created within
lib/middleware.js
by including aheaders
property in the main options object passed inbroccoli.server.serve(builder, options)
. For example, the following options would enable Broccoli to include a CORS header when serving files onhttp://localhost:4200
:To allow advanced options like these to be easier configure when using Broccoli CLI, this pull request also expands on
lib/cli.js
by allowing users to define an optional.broccoli
JSON-formatted file within the root directory of their projects. Any configurations defined within that.broccoli
file will be pulled whenever callingbroccoli serve
. For example, the following.broccoli
file would cause Broccoli to serve on port 12345 with a CORS header:This pull request includes 5 new passing tests in
test/options_test.js
. To help clean up the console output when running Mocha, there is new option defined calleddisableLogging
which (when set totrue
) will causelib/server.js
to not callconsole.log()
while the Mocha tests are running.