Forked from anonymous/gist:75d655df03dc5a906b887dd9b230491c
Created
October 25, 2017 23:11
-
-
Save devinus/76ccdaf1467f75680f57c67f5a2b55ac to your computer and use it in GitHub Desktop.
Getting fastboot POSTs working for ember serve:
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// 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