This repository was archived by the owner on Feb 12, 2024. It is now read-only.
File tree 2 files changed +28
-24
lines changed
2 files changed +28
-24
lines changed Original file line number Diff line number Diff line change @@ -79,10 +79,10 @@ module.exports = {
79
79
try {
80
80
await daemon . start ( )
81
81
daemon . _httpApi . _apiServers . forEach ( apiServer => {
82
- print ( `API listening on ${ apiServer . info . ma . toString ( ) } ` )
82
+ print ( `API listening on ${ apiServer . info . ma } ` )
83
83
} )
84
84
daemon . _httpApi . _gatewayServers . forEach ( gatewayServer => {
85
- print ( `Gateway (read only) listening on ${ gatewayServer . info . ma . toString ( ) } ` )
85
+ print ( `Gateway (read only) listening on ${ gatewayServer . info . ma } ` )
86
86
} )
87
87
daemon . _httpApi . _apiServers . forEach ( apiServer => {
88
88
print ( `Web UI available at ${ toUri ( apiServer . info . ma ) } /webui` )
Original file line number Diff line number Diff line change 1
1
'use strict'
2
2
3
- const Joi = require ( '@hapi/joi' )
4
- const resources = require ( '../../gateway/resources' )
3
+ const multiaddr = require ( 'multiaddr' )
4
+ const debug = require ( 'debug' )
5
+ const log = debug ( 'ipfs:webui:info' )
6
+ log . error = debug ( 'ipfs:webui:error' )
5
7
6
8
module . exports = [
7
- {
8
- method : '*' ,
9
- path : '/ipfs/{path*}' ,
10
- options : {
11
- handler : resources . gateway . handler ,
12
- validate : {
13
- params : {
14
- path : Joi . string ( ) . required ( )
15
- }
16
- } ,
17
- response : {
18
- ranges : false // disable built-in support, handler does it manually
19
- } ,
20
- ext : {
21
- onPostHandler : { method : resources . gateway . afterHandler }
22
- }
23
- }
24
- } ,
25
9
{
26
10
method : '*' ,
27
11
path : '/webui' ,
28
- handler ( request , h ) {
29
- return h . redirect ( '/ipfs/QmPURAjo3oneGH53ovt68UZEBvsc8nNmEhQZEpsVEQUMZE' )
12
+ async handler ( request , h ) {
13
+ let scheme = 'http'
14
+ let port
15
+ let host
16
+
17
+ try {
18
+ const { ipfs } = request . server . app
19
+ const gateway = await ipfs . config . get ( 'Addresses.Gateway' )
20
+ const address = multiaddr ( gateway ) . nodeAddress ( )
21
+
22
+ port = address . port
23
+ host = address . host
24
+ } catch ( err ) {
25
+ // may not have gateway configured
26
+ log . error ( err )
27
+
28
+ scheme = 'https'
29
+ port = 443
30
+ host = 'gateway.ipfs.io'
31
+ }
32
+
33
+ return h . redirect ( `${ scheme } ://${ host } :${ port } /ipns/webui.ipfs.io` )
30
34
}
31
35
}
32
36
]
You can’t perform that action at this time.
0 commit comments