Skip to content

Commit

Permalink
Merge pull request #472 from ipfs-shipyard/fix/wss-redirect
Browse files Browse the repository at this point in the history
Skip HTTP GET of websocket handshake
  • Loading branch information
lidel authored May 2, 2018
2 parents 0598d1f + 8176948 commit 2de4726
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 0 deletions.
4 changes: 4 additions & 0 deletions add-on/src/lib/ipfs-companion.js
Original file line number Diff line number Diff line change
Expand Up @@ -99,6 +99,10 @@ module.exports = async function init () {
// ===================================================================

function onBeforeSendHeaders (request) {
// skip websocket handshake (not supported by HTTP2IPFS gateways)
if (request.type === 'websocket') {
return
}
if (request.url.startsWith(state.apiURLString)) {
// For some reason js-ipfs-api sent requests with "Origin: null" under Chrome
// which produced '403 - Forbidden' error.
Expand Down
5 changes: 5 additions & 0 deletions add-on/src/lib/ipfs-request.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,11 @@ function createRequestModifier (getState, dnsLink, ipfsPathValidator) {
return
}

// skip websocket handshake (not supported by HTTP2IPFS gateways)
if (request.type === 'websocket') {
return
}

// skip all local requests
if (request.url.startsWith('http://127.0.0.1:') || request.url.startsWith('http://localhost:') || request.url.startsWith('http://[::1]:')) {
return
Expand Down

0 comments on commit 2de4726

Please sign in to comment.