Skip to content

Instantly share code, notes, and snippets.

Created October 25, 2017 23:00
Show Gist options
  • Save anonymous/75d655df03dc5a906b887dd9b230491c to your computer and use it in GitHub Desktop.
Save anonymous/75d655df03dc5a906b887dd9b230491c to your computer and use it in GitHub Desktop.
Getting fastboot POSTs working for ember serve:
// lib/post-middleware/package.json
{
"name": "post-middlware",
"keywords": [
"ember-addon"
],
"ember-addon": {
"before": "broccoli-watcher"
}
}
// lib/post-middleware/index.js
/*eslint-env node */
const HistorySupport = require('./history-support-addon'); (change to real history support lib path in ember-cli if >= 2.16)
const cleanBaseURL = require('clean-base-url');
class PostFriendlyHistorySupport extends HistorySupport {
constructor(project) {
super(project);
}
shouldAddMiddleware(environment) {
let config = this.project.config(environment);
let locationType = config.locationType;
return ['auto', 'history'].indexOf(locationType) !== -1;
}
shouldHandleRequest(req, options) {
//code here to allow POSTs
}
module.exports = PostFriendlyHistorySupport;
// package.json
...
"ember-addon": {
"paths": [
"lib/post-middleware"
],
...
// config/environment.js
...
historySupportMiddleware: false,
...
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment