From 41c82e1ea9d11d350cf0cc61ab09f813bfacd20d Mon Sep 17 00:00:00 2001 From: NBTX Date: Fri, 25 Oct 2019 21:14:49 +0100 Subject: [PATCH] Remove legacy proxy server middleware --- nuxt.config.js | 3 --- proxy/index.js | 58 -------------------------------------------------- 2 files changed, 61 deletions(-) delete mode 100644 proxy/index.js diff --git a/nuxt.config.js b/nuxt.config.js index a08ee50a4..2e197c22a 100644 --- a/nuxt.config.js +++ b/nuxt.config.js @@ -27,9 +27,6 @@ export default { server: { host: '0.0.0.0', // default: localhost }, - serverMiddleware: [ - '~/proxy/index.js' - ], head: { title: `${meta.name} \u2022 ${meta.shortDescription}`, meta: [ diff --git a/proxy/index.js b/proxy/index.js deleted file mode 100644 index 847e33514..000000000 --- a/proxy/index.js +++ /dev/null @@ -1,58 +0,0 @@ -import express from 'express'; -import bodyParser from 'body-parser'; -import axios from 'axios'; - -const app = express(); - -app.use(bodyParser.json()); - -app.use((req, res, next) => { - res.header('Access-Control-Allow-Origin', '*'); - res.header('Access-Control-Allow-Headers', '*'); - next(); -}); - -app.post('/', async (req, res) => { - const { - method, - url, - auth, - headers, - data - } = req.body; - - try { - const payload = await axios({ - method, - url, - auth, - headers, - data - }); - - return await res.json({ - data: payload.data, - status: payload.status, - statusText: payload.statusText, - headers: payload.headers, - }); - - } catch (error) { - if (error.response) { - const errorResponse = error.response; - return await res.json({ - data: errorResponse.data, - status: errorResponse.status, - statusText: errorResponse.statusText, - headers: errorResponse.headers, - }); - } else { - return res.status(500).send(); - } - } -}); - -export default { - path: '/proxy', - handler: app -}