diff --git a/src/config.ts b/src/config.ts index d6b1af0e35..7c6ecaab25 100644 --- a/src/config.ts +++ b/src/config.ts @@ -58,7 +58,6 @@ interface Mixin { auth_url: string; dev_url: string; drive_url: string; - proxy_url: string; } export type IConfig = ISource & Mixin; @@ -90,7 +89,6 @@ export default (path: string) => { mixin.auth_url = `${mixin.scheme}://auth.${mixin.host}`; mixin.dev_url = `${mixin.scheme}://dev.${mixin.host}`; mixin.drive_url = `${mixin.secondary_scheme}://file.${mixin.secondary_host}`; - mixin.proxy_url = `${mixin.secondary_scheme}://proxy.${mixin.secondary_host}`; return Object.assign(config || {}, mixin) as IConfig; }; diff --git a/src/server.ts b/src/server.ts index 421ad60c1f..5ab6f3be5b 100644 --- a/src/server.ts +++ b/src/server.ts @@ -29,7 +29,6 @@ app.use((req, res, next) => { app.use(vhost(`api.${config.host}`, require('./api/server'))); app.use(vhost(config.secondary_host, require('./himasaku/server'))); app.use(vhost(`file.${config.secondary_host}`, require('./file/server'))); -app.use(vhost(`proxy.${config.secondary_host}`, require('./web/service/proxy/server'))); app.use(require('./web/server')); /** diff --git a/src/web/service/proxy/proxy.ts b/src/web/service/proxy/proxy.ts deleted file mode 100644 index 48c9fa4a53..0000000000 --- a/src/web/service/proxy/proxy.ts +++ /dev/null @@ -1,31 +0,0 @@ -import * as URL from 'url'; -import * as express from 'express'; -import * as request from 'request'; -import * as isUrl from 'is-url'; - -module.exports = (req: express.Request, res: express.Response) => { - const url = req.params.url; - - if (!url || !isUrl(url)) { - return; - } - - request({ - url: url + URL.parse(req.url, true).search, - encoding: null - }, (err, response, content) => { - if (err) { - console.error(err); - return; - } - - const contentType = response.headers['content-type']; - - if (/^text\//.test(contentType) || contentType === 'application/javascript') { - content = content.toString().replace(/http:\/\//g, `${config.secondary_scheme}://proxy.${config.secondary_host}/http://`); - } - - res.header('Content-Type', contentType); - res.send(content); - }); -}; diff --git a/src/web/service/proxy/server.ts b/src/web/service/proxy/server.ts deleted file mode 100644 index 5b1b8d106c..0000000000 --- a/src/web/service/proxy/server.ts +++ /dev/null @@ -1,17 +0,0 @@ -/** - * Forward Proxy Service - */ - -import * as express from 'express'; -import * as cors from 'cors'; - -/** - * Init app - */ -const app = express(); -app.disable('x-powered-by'); -app.use(cors()); - -app.get('/:url(*)', require('./proxy')); - -module.exports = app; diff --git a/src/web/service/url-preview.ts b/src/web/service/url-preview.ts index d1a345ef17..0c5fd8a78e 100644 --- a/src/web/service/url-preview.ts +++ b/src/web/service/url-preview.ts @@ -9,5 +9,7 @@ module.exports = async (req: express.Request, res: express.Response) => { }; function wrap(url: string): string { - return `${config.proxy_url}/${url}`; + return url != null + ? `https://images.weserv.nl/?url=${url.replace(/^https?:\/\//, '')}` + : null; }