mirror of
https://github.com/paricafe/misskey.git
synced 2024-11-24 16:26:44 -06:00
parent
65a5373acb
commit
27c6ebebc0
5 changed files with 3 additions and 52 deletions
|
@ -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;
|
||||
};
|
||||
|
|
|
@ -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'));
|
||||
|
||||
/**
|
||||
|
|
|
@ -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);
|
||||
});
|
||||
};
|
|
@ -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;
|
|
@ -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;
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue