From 34851a70780214cd69c3f8c50dfe363d6bf2cacd Mon Sep 17 00:00:00 2001 From: PJ Date: Thu, 23 Jan 2020 21:02:04 +0100 Subject: [PATCH] Revert proxy handler --- packages/siaviewnode-server/src/main.ts | 30 ++++++++++++------------- 1 file changed, 15 insertions(+), 15 deletions(-) diff --git a/packages/siaviewnode-server/src/main.ts b/packages/siaviewnode-server/src/main.ts index b8e58ab0..0416781d 100644 --- a/packages/siaviewnode-server/src/main.ts +++ b/packages/siaviewnode-server/src/main.ts @@ -1,4 +1,5 @@ import axios from "axios" +import * as AxiosLogger from 'axios-logger' import cors from "cors" import express, { Request, Response } from "express" import fileUpload, { UploadedFile } from "express-fileupload" @@ -9,7 +10,6 @@ import R from "ramda" import shortid from "shortid" import { Logger } from "winston" import logger from "./logger" -import * as AxiosLogger from 'axios-logger'; const MAX_UPLOAD_FILESIZE = 1000 * 1024 * 1024 @@ -84,9 +84,22 @@ export class Server { } private configureRoutes() { - this.app.get("/sialink/:hash", this.handleSialinkGET.bind(this)) this.app.post("/siafile", this.handleSiafilePOST.bind(this)) this.app.post("/linkfile", this.handleLinkfilePOST.bind(this)) + + this.app.get( + "/sialink/:hash", + proxy("http://localhost:9980/renter/sialink", { + proxyReqOptDecorator: (opts, _) => { + opts.headers["User-Agent"] = "Sia-Agent" + return opts + }, + proxyReqPathResolver: req => { + const { hash } = req.params + return `/renter/sialink/${hash}` + } + }) + ) } private async verifyConnection(): Promise { @@ -100,19 +113,6 @@ export class Server { } } - private handleSialinkGET() { - return proxy(`${SIAD_ENDPOINT}/renter/sialink`, { - proxyReqOptDecorator: (opts, _) => { - opts.headers["User-Agent"] = "Sia-Agent" - return opts - }, - proxyReqPathResolver: req => { - const { hash } = req.params - return `/renter/sialink/${hash}` - } - }) - } - private async handleLinkfilePOST(req: Request, res: Response): Promise { const file = selectFile(req) as UploadedFile const uid = shortid.generate()