Skip to content

Commit

Permalink
Merge pull request #2559 from miragejs/restore-usingProxy
Browse files Browse the repository at this point in the history
Restore usingProxy config
  • Loading branch information
SergeAstapov authored Oct 13, 2023
2 parents dc38525 + ffe05a7 commit ca7e642
Showing 1 changed file with 31 additions and 0 deletions.
31 changes: 31 additions & 0 deletions packages/ember-cli-mirage/config/environment.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
'use strict';
const fs = require('fs');

function usingProxy() {
const usingProxyArg = !!process.argv.filter(function (arg) {
return (
arg.indexOf('--proxy') === 0 ||
arg.indexOf('-pr') === 0 ||
arg.indexOf('-pxy') === 0
);
}).length;

let hasGeneratedProxies = false;
const proxiesDir = `${process.env.PWD}/server/proxies`;
try {
fs.lstatSync(proxiesDir);
hasGeneratedProxies = true;
} catch (e) {
// ignore
}

return usingProxyArg || hasGeneratedProxies;
}

module.exports = function (environment, appConfig) {
appConfig['ember-cli-mirage'] = appConfig['ember-cli-mirage'] || {};
appConfig['ember-cli-mirage'].usingProxy = usingProxy();
appConfig['ember-cli-mirage'].useDefaultPassthroughs = true;

return {};
};

0 comments on commit ca7e642

Please # to comment.