Skip to content
This repository has been archived by the owner on Nov 6, 2020. It is now read-only.

Commit

Permalink
Handle redirects from /api/content on manifest.json gracefully (#3315)
Browse files Browse the repository at this point in the history
* Add redirect follow mode to manifest.json

* Remove (now) unused count parameter

* autoRewrite: true for dev mode proxy redirects
  • Loading branch information
jacogr authored and arkpar committed Nov 9, 2016
1 parent 3695f86 commit 73cd4ac
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 17 deletions.
23 changes: 7 additions & 16 deletions js/src/views/Dapps/dappsStore.js
Original file line number Diff line number Diff line change
Expand Up @@ -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;
});
}
Expand Down
3 changes: 2 additions & 1 deletion js/webpack.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -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',
Expand Down

0 comments on commit 73cd4ac

Please sign in to comment.