Suggest: use window.location to get host and port for API, make easy for visit from other machine
- Dominant language
- JavaScript
- Stars
- 1.6k
- Forks
- 534
- PR merge metrics
- No merged PRs in 30d
Description
Expose API, Allow CORS:
```
"API": {
"HTTPHeaders": {
"Access-Control-Allow-Credentials": [
"true"
],
"Access-Control-Allow-Methods": [
"PUT",
"GET",
"POST"
],
"Access-Control-Allow-Origin": [
"*"
]
}
},
"Addresses": {
"API": "/ip4/0.0.0.0/tcp/5001",
"Announce": [],
"Gateway": "/ip4/0.0.0.0/tcp/6001",
"NoAnnounce": [],
"Swarm": [
"/ip4/0.0.0.0/tcp/4001",
"/ip6/::/tcp/4001"
]
}
```
Visit webui from other machine. I must use `localStorage.setItem('ipfsApi', '/ip4/node_ip/tcp/5001')` to change the API. **And its not work when use domain name.**
### Why not use `window.location.hostname` to get the host, `window.location.port` to get the port?
Port of webui always same as API port. Visit `http://192.168.1.6:5001/webui`, means: i need to use `/ip4/192.168.1.6/tcp/5001` API. This is in line with expected behavior. And no need: `Is your API on a port other than 5001?` set form.
### Wrong gateway address when click a mp4 file
Click Files Tab, then click mp4 file. webui use `http://0.0.0.0:6001/ipfs/QmY8Xhcn8JS79QwJXCW95Lbqp4EoJap9pqfaAFGyRfjSyz` as source:
```
```
Its better to use:
```
const geatewayPort = getGatewayPortFromConfig();
const gateway = `${window.location.protocol}//${window.location.hostname}:${geatewayPort}/ipfs/${qm}`
```
Contributor guide
No contributing guide indexed for this repository
Assessment
This issue has not been assessed yet.