Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: support POST-only HTTP API #1430

Merged
merged 2 commits into from
Apr 4, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ Run the **[cors-config.sh](./cors-config.sh)** script with:

```sh
> ipfs config --json API.HTTPHeaders.Access-Control-Allow-Origin '["http://localhost:3000", "https://webui.ipfs.io"]'
> ipfs config --json API.HTTPHeaders.Access-Control-Allow-Methods '["PUT", "GET", "POST"]'
> ipfs config --json API.HTTPHeaders.Access-Control-Allow-Methods '["PUT", "POST"]'
```

#### Reverting
Expand Down
2 changes: 1 addition & 1 deletion cors-config.sh
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ ALLOW_ORIGINS='"http://localhost:3000", "https://webui.ipfs.io"'
set -e

ipfs config --json API.HTTPHeaders.Access-Control-Allow-Origin "[$ALLOW_ORIGINS]"
ipfs config --json API.HTTPHeaders.Access-Control-Allow-Methods '["PUT", "GET", "POST"]'
ipfs config --json API.HTTPHeaders.Access-Control-Allow-Methods '["PUT", "POST"]'

echo "IPFS API CORS headers configured for $ALLOW_ORIGINS"
echo "Please restart your IPFS daemon"
65 changes: 65 additions & 0 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 2 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
"version": "2.7.2",
"private": true,
"scripts": {
"postinstall": "patch-package",
"start": "run-script-os",
"start:win32": "@powershell -Command $env:REACT_APP_GIT_REV=(git rev-parse --short HEAD); react-scripts start",
"start:darwin:linux": "cross-env REACT_APP_GIT_REV=`git rev-parse --short HEAD` react-scripts start",
Expand Down Expand Up @@ -55,6 +56,7 @@
"multiaddr": "^7.2.1",
"multiaddr-to-uri": "^5.1.0",
"p-queue": "^6.2.1",
"patch-package": "6.2.2",
"prop-types": "^15.7.2",
"pull-file-reader": "^1.0.2",
"react": "^16.12.0",
Expand Down
91 changes: 91 additions & 0 deletions patches/ipfs-http-client+39.0.2.patch
Original file line number Diff line number Diff line change
@@ -0,0 +1,91 @@
diff --git a/node_modules/ipfs-http-client/src/config/profiles/list.js b/node_modules/ipfs-http-client/src/config/profiles/list.js
index dbfa579..6f501f7 100644
--- a/node_modules/ipfs-http-client/src/config/profiles/list.js
+++ b/node_modules/ipfs-http-client/src/config/profiles/list.js
@@ -8,7 +8,7 @@ module.exports = configure(({ ky }) => {
return callbackify.variadic(async (options) => {
options = options || {}

- const res = await ky.get('config/profile/list', {
+ const res = await ky.post('config/profile/list', {
timeout: options.timeout,
signal: options.signal,
headers: options.headers
diff --git a/node_modules/ipfs-http-client/src/files-regular/get.js b/node_modules/ipfs-http-client/src/files-regular/get.js
index 6c94264..68e15fe 100644
--- a/node_modules/ipfs-http-client/src/files-regular/get.js
+++ b/node_modules/ipfs-http-client/src/files-regular/get.js
@@ -36,7 +36,7 @@ module.exports = configure(({ ky }) => {
searchParams.set('length', options.length)
}

- const res = await ky.get('get', {
+ const res = await ky.post('get', {
timeout: options.timeout,
signal: options.signal,
headers: options.headers,
diff --git a/node_modules/ipfs-http-client/src/files-regular/ls.js b/node_modules/ipfs-http-client/src/files-regular/ls.js
index 0f13f55..d81a963 100644
--- a/node_modules/ipfs-http-client/src/files-regular/ls.js
+++ b/node_modules/ipfs-http-client/src/files-regular/ls.js
@@ -31,7 +31,7 @@ module.exports = configure(({ ky }) => {
searchParams.set('recursive', options.recursive)
}

- const res = await ky.get('ls', {
+ const res = await ky.post('ls', {
timeout: options.timeout,
signal: options.signal,
headers: options.headers,
diff --git a/node_modules/ipfs-http-client/src/files-regular/refs-local.js b/node_modules/ipfs-http-client/src/files-regular/refs-local.js
index efb8d32..afa1630 100644
--- a/node_modules/ipfs-http-client/src/files-regular/refs-local.js
+++ b/node_modules/ipfs-http-client/src/files-regular/refs-local.js
@@ -9,7 +9,7 @@ module.exports = configure(({ ky }) => {
return async function * refsLocal (options) {
options = options || {}

- const res = await ky.get('refs/local', {
+ const res = await ky.post('refs/local', {
timeout: options.timeout,
signal: options.signal,
headers: options.headers
diff --git a/node_modules/ipfs-http-client/src/files-regular/refs.js b/node_modules/ipfs-http-client/src/files-regular/refs.js
index c6136ed..dbeb9a1 100644
--- a/node_modules/ipfs-http-client/src/files-regular/refs.js
+++ b/node_modules/ipfs-http-client/src/files-regular/refs.js
@@ -49,7 +49,7 @@ module.exports = configure(({ ky }) => {
searchParams.append('arg', arg.toString())
}

- const res = await ky.get('refs', {
+ const res = await ky.post('refs', {
timeout: options.timeout,
signal: options.signal,
headers: options.headers,
diff --git a/node_modules/ipfs-http-client/src/pubsub/ls.js b/node_modules/ipfs-http-client/src/pubsub/ls.js
index 177dcd4..d2bc8f6 100644
--- a/node_modules/ipfs-http-client/src/pubsub/ls.js
+++ b/node_modules/ipfs-http-client/src/pubsub/ls.js
@@ -6,7 +6,7 @@ module.exports = configure(({ ky }) => {
return async (options) => {
options = options || {}

- const { Strings } = await ky.get('pubsub/ls', {
+ const { Strings } = await ky.post('pubsub/ls', {
timeout: options.timeout,
signal: options.signal,
headers: options.headers,
diff --git a/node_modules/ipfs-http-client/src/pubsub/peers.js b/node_modules/ipfs-http-client/src/pubsub/peers.js
index bdeca60..5fa5b24 100644
--- a/node_modules/ipfs-http-client/src/pubsub/peers.js
+++ b/node_modules/ipfs-http-client/src/pubsub/peers.js
@@ -14,7 +14,7 @@ module.exports = configure(({ ky }) => {
const searchParams = new URLSearchParams(options.searchParams)
searchParams.set('arg', topic)

- const { Strings } = await ky.get('pubsub/peers', {
+ const { Strings } = await ky.post('pubsub/peers', {
timeout: options.timeout,
signal: options.signal,
headers: options.headers,
2 changes: 1 addition & 1 deletion src/welcome/WelcomePage.js
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@ const ConnectionStatus = ({ t, connected, sameOrigin }) => {
</Trans>
<Shell>
<code className='db'>$ ipfs config --json API.HTTPHeaders.Access-Control-Allow-Origin '[{addOrigin && `"${origin}", `}"{defaultDomains.join('", "')}"]'</code>
<code className='db'>$ ipfs config --json API.HTTPHeaders.Access-Control-Allow-Methods '["PUT", "GET", "POST"]'</code>
<code className='db'>$ ipfs config --json API.HTTPHeaders.Access-Control-Allow-Methods '["PUT", "POST"]'</code>
</Shell>
</div>
)}
Expand Down