diff --git a/frontend/url.ts b/frontend/url.ts index 74a836e0b9..7df15f7da3 100644 --- a/frontend/url.ts +++ b/frontend/url.ts @@ -1,16 +1,32 @@ // Copyright (c) 2016 Brandon Thomas +import $ = require('jquery'); import { RawSentence, FilteredSentence } from "./sentence"; import URI = require('urijs'); +/** + * The API server hostname (including HTTP scheme). + * This is injected into the meta tags before upload so we can build the path. + */ +function getApiHost(): string { + let environment = $('meta[name=environment]').attr('content'); + switch (environment.toLowerCase()) { + case 'production': + return $('meta[name=api_host]').attr('content'); + default: + return ''; + } +} + /** * Sentence -> Audio generation API URL */ export function get_audio_api_url(sentence: FilteredSentence) : string { // I may expand the API later, but for now this is all I'll expose. - let encoded = encodeURIComponent(sentence.value); - return `/speak?v=trump&vol=3&s=${encoded}`; + let apiHost = getApiHost(), + encoded = encodeURIComponent(sentence.value); + return `${apiHost}/speak?v=trump&vol=3&s=${encoded}`; } /** diff --git a/s3-deploy.sh b/s3-deploy.sh index 3f63e6c65e..7d96571877 100755 --- a/s3-deploy.sh +++ b/s3-deploy.sh @@ -36,8 +36,10 @@ pushd $output_dir > /dev/null sed -i "s/assets\/output/assets/g" index.html # /assets/main.built.js -> //cdn.junglehorse.com/assets/${checksum}/main.built.js sed -i "s/\/assets/\/\/cdn.junglehorse.com\/assets\/${checksum}/g" index.html +# Variable substitutions sed -i "s/asset_content_hash/${checksum}/g" index.html sed -i "s/DEVELOPMENT/production/g" index.html +sed -i "s/API_HOST/http:\/\/jungle.horse/g" index.html popd > /dev/null echo "> Upload to S3." diff --git a/web/index.html b/web/index.html index 73d11f0102..00fe7349b0 100644 --- a/web/index.html +++ b/web/index.html @@ -10,6 +10,7 @@ +