More flexible API URL (necessary for testing)

This commit is contained in:
Toby Zerner 2015-01-23 12:48:21 +10:30
parent cd0b6300d8
commit a9b19f62e0
4 changed files with 8 additions and 5 deletions

View File

@ -1,8 +1,9 @@
import JsonApiAdapter from 'ember-json-api/json-api-adapter'; import JsonApiAdapter from 'ember-json-api/json-api-adapter';
import config from '../config/environment';
export default JsonApiAdapter.extend({ export default JsonApiAdapter.extend({
// Todo: make this loaded via an environment variable or something // Todo: make this loaded via an environment variable or something
host: '/api' host: config.apiURL
}); });

View File

@ -5,6 +5,7 @@ module.exports = function(environment) {
modulePrefix: 'flarum', modulePrefix: 'flarum',
environment: environment, environment: environment,
baseURL: '/', baseURL: '/',
apiURL: '/api',
locationType: 'hash', locationType: 'hash',
EmberENV: { EmberENV: {
FEATURES: { FEATURES: {
@ -31,6 +32,7 @@ module.exports = function(environment) {
// Testem prefers this... // Testem prefers this...
ENV.baseURL = '/'; ENV.baseURL = '/';
ENV.locationType = 'none'; ENV.locationType = 'none';
ENV.apiURL = 'http://flarum.dev/api',
// keep test console output quieter // keep test console output quieter
ENV.APP.LOG_ACTIVE_GENERATION = false; ENV.APP.LOG_ACTIVE_GENERATION = false;

View File

@ -142,8 +142,8 @@ abstract class Base extends Controller
protected function respondWithArray($array, $statusCode = 200, $headers = []) protected function respondWithArray($array, $statusCode = 200, $headers = [])
{ {
// @todo remove this // @todo remove this?
$headers['Access-Control-Allow-Origin'] = 'http://0.0.0.0:4200'; $headers['Access-Control-Allow-Origin'] = '*';
return Response::json($array, $statusCode, $headers); return Response::json($array, $statusCode, $headers);
} }

View File

@ -9,8 +9,8 @@
<meta name="mobile-web-app-capable" content="yes"> <meta name="mobile-web-app-capable" content="yes">
<meta name="apple-mobile-web-app-capable" content="yes"> <meta name="apple-mobile-web-app-capable" content="yes">
<meta name="flarum/config/environment" content="%7B%22modulePrefix%22%3A%22flarum%22%2C%22environment%22%3A%22development%22%2C%22baseURL%22%3A%22/%22%2C%22locationType%22%3A%22hash%22%2C%22EmberENV%22%3A%7B%22FEATURES%22%3A%7B%7D%7D%2C%22APP%22%3A%7B%22LOG_ACTIVE_GENERATION%22%3Atrue%2C%22LOG_VIEW_LOOKUPS%22%3Atrue%7D%2C%22contentSecurityPolicyHeader%22%3A%22Content-Security-Policy-Report-Only%22%2C%22contentSecurityPolicy%22%3A%7B%22default-src%22%3A%22%27none%27%22%2C%22script-src%22%3A%22%27self%27%20%27unsafe-eval%27%22%2C%22font-src%22%3A%22%27self%27%22%2C%22connect-src%22%3A%22%27self%27%22%2C%22img-src%22%3A%22%27self%27%22%2C%22style-src%22%3A%22%27self%27%22%2C%22media-src%22%3A%22%27self%27%22%7D%2C%22exportApplicationGlobal%22%3Atrue%7D" /> <meta name="flarum/config/environment" content="%7B%22modulePrefix%22%3A%22flarum%22%2C%22environment%22%3A%22development%22%2C%22baseURL%22%3A%22/%22%2C%22apiURL%22%3A%22/api%22%2C%22locationType%22%3A%22hash%22%2C%22EmberENV%22%3A%7B%22FEATURES%22%3A%7B%7D%7D%2C%22APP%22%3A%7B%7D%2C%22contentSecurityPolicyHeader%22%3A%22Content-Security-Policy-Report-Only%22%2C%22contentSecurityPolicy%22%3A%7B%22default-src%22%3A%22%27none%27%22%2C%22script-src%22%3A%22%27self%27%20%27unsafe-eval%27%22%2C%22font-src%22%3A%22%27self%27%22%2C%22connect-src%22%3A%22%27self%27%22%2C%22img-src%22%3A%22%27self%27%22%2C%22style-src%22%3A%22%27self%27%22%2C%22media-src%22%3A%22%27self%27%22%7D%2C%22exportApplicationGlobal%22%3Atrue%7D" />
<base href="/"> <base href="/">
{{ app('flarum.web.assetManager')->styles() }} {{ app('flarum.web.assetManager')->styles() }}