Skip to content

Commit 68db59f

Browse files
authored
add proxy endpoint for retrieveing the backpack (explorer) (#1259)
* add proxy endpoint for retrieveing the backpack (explorer) * add suggested code review
1 parent 100f738 commit 68db59f

1 file changed

Lines changed: 19 additions & 0 deletions

File tree

  • packages/@dcl/sdk-commands/src/commands/start/server

packages/@dcl/sdk-commands/src/commands/start/server/endpoints.ts

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -137,6 +137,25 @@ export async function setupEcs6Endpoints(
137137
return res
138138
})
139139

140+
router.all('/explorer/:path+', async (ctx) => {
141+
const u = new URL(ctx.url.toString())
142+
u.host = catalystUrl.host
143+
u.protocol = catalystUrl.protocol
144+
u.port = catalystUrl.port
145+
const req = await fetch(u.toString(), {
146+
headers: { connection: 'close' },
147+
method: ctx.request.method,
148+
body: ctx.request.method === 'get' ? undefined : ctx.request.body
149+
})
150+
151+
return {
152+
headers: {
153+
'content-type': req.headers.get('content-type') || 'application/json'
154+
},
155+
body: req.body
156+
}
157+
})
158+
140159
serveStatic(components, workspace, router)
141160

142161
// TODO: get workspace scenes & wearables...

0 commit comments

Comments
 (0)