parent
a7fdaf80fd
commit
f241a46e05
4
package-lock.json
generated
4
package-lock.json
generated
@ -1,12 +1,12 @@
|
|||||||
{
|
{
|
||||||
"name": "txtdot",
|
"name": "txtdot",
|
||||||
"version": "1.6.0",
|
"version": "1.6.1",
|
||||||
"lockfileVersion": 3,
|
"lockfileVersion": 3,
|
||||||
"requires": true,
|
"requires": true,
|
||||||
"packages": {
|
"packages": {
|
||||||
"": {
|
"": {
|
||||||
"name": "txtdot",
|
"name": "txtdot",
|
||||||
"version": "1.6.0",
|
"version": "1.6.1",
|
||||||
"license": "MIT",
|
"license": "MIT",
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"@fastify/static": "^6.12.0",
|
"@fastify/static": "^6.12.0",
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
{
|
{
|
||||||
"name": "txtdot",
|
"name": "txtdot",
|
||||||
"version": "1.6.0",
|
"version": "1.6.1",
|
||||||
"private": true,
|
"private": true,
|
||||||
"description": "txtdot is an HTTP proxy that parses only text, links and pictures from pages reducing internet bandwidth usage, removing ads and heavy scripts",
|
"description": "txtdot is an HTTP proxy that parses only text, links and pictures from pages reducing internet bandwidth usage, removing ads and heavy scripts",
|
||||||
"main": "dist/app.js",
|
"main": "dist/app.js",
|
||||||
|
@ -2,11 +2,18 @@ import { FastifyInstance } from 'fastify';
|
|||||||
import { IProxySchema, ProxySchema } from '../../types/requests/browser';
|
import { IProxySchema, ProxySchema } from '../../types/requests/browser';
|
||||||
import axios from '../../types/axios';
|
import axios from '../../types/axios';
|
||||||
|
|
||||||
|
import isLocalResource from '../../utils/islocal';
|
||||||
|
import { LocalResourceError } from '../../errors/main';
|
||||||
|
|
||||||
export default async function proxyRoute(fastify: FastifyInstance) {
|
export default async function proxyRoute(fastify: FastifyInstance) {
|
||||||
fastify.get<IProxySchema>(
|
fastify.get<IProxySchema>(
|
||||||
'/proxy',
|
'/proxy',
|
||||||
{ schema: ProxySchema },
|
{ schema: ProxySchema },
|
||||||
async (request, reply) => {
|
async (request, reply) => {
|
||||||
|
if (await isLocalResource(new URL(request.query.url))) {
|
||||||
|
throw new LocalResourceError();
|
||||||
|
}
|
||||||
|
|
||||||
const response = await axios.get(request.query.url);
|
const response = await axios.get(request.query.url);
|
||||||
const mime: string | undefined =
|
const mime: string | undefined =
|
||||||
response.headers['content-type']?.toString();
|
response.headers['content-type']?.toString();
|
||||||
|
Loading…
x
Reference in New Issue
Block a user