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


Former-commit-id: 73143932199b78961760208a9f20dac62b55f0bd
This commit is contained in:
Jaco Greeff 2016-11-09 20:05:08 +01:00 committed by Arkadiy Paronyan
parent e8d6c3a699
commit 8660b057bf
2 changed files with 9 additions and 17 deletions

View File

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

View File

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