Handle redirects from /api/content on manifest.json gracefully (#3315)

* Add redirect follow mode to manifest.json

* Remove (now) unused count parameter

* autoRewrite: true for dev mode proxy redirects
This commit is contained in:
Jaco Greeff 2016-11-09 20:05:08 +01:00 committed by Arkadiy Paronyan
parent 88c9cea04d
commit 90ff810e36
2 changed files with 9 additions and 17 deletions

View File

@ -197,24 +197,15 @@ export default class DappsStore {
});
}
_fetchManifest (manifestHash, count = 0) {
return fetch(`${this._getHost()}/api/content/${manifestHash}/`)
_fetchManifest (manifestHash) {
return fetch(`${this._getHost()}/api/content/${manifestHash}/`, { redirect: 'follow', mode: 'cors' })
.then((response) => {
if (response.ok) {
return response.json();
}
if (count < 1) {
return this._fetchManifest(manifestHash, count + 1);
}
return null;
return response.ok
? response.json()
: null;
})
.catch(() => {
if (count < 1) {
return this._fetchManifest(manifestHash, count + 1);
}
.catch((error) => {
console.warn('DappsStore:fetchManifest', error);
return null;
});
}

View File

@ -198,7 +198,8 @@ module.exports = {
proxy: {
'/api/*': {
target: 'http://127.0.0.1:8080',
changeOrigin: true
changeOrigin: true,
autoRewrite: true
},
'/app/*': {
target: 'http://127.0.0.1:8080',