Skip to content

Commit

Permalink
fix: isLocalResourse for proxy (#103)
Browse files Browse the repository at this point in the history
  • Loading branch information
artegoser committed Mar 5, 2024
1 parent a7fdaf8 commit f241a46
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 3 deletions.
4 changes: 2 additions & 2 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "txtdot",
"version": "1.6.0",
"version": "1.6.1",
"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",
"main": "dist/app.js",
Expand Down
7 changes: 7 additions & 0 deletions src/routes/browser/proxy.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,18 @@ import { FastifyInstance } from 'fastify';
import { IProxySchema, ProxySchema } from '../../types/requests/browser';
import axios from '../../types/axios';

import isLocalResource from '../../utils/islocal';
import { LocalResourceError } from '../../errors/main';

export default async function proxyRoute(fastify: FastifyInstance) {
fastify.get<IProxySchema>(
'/proxy',
{ schema: ProxySchema },
async (request, reply) => {
if (await isLocalResource(new URL(request.query.url))) {
throw new LocalResourceError();
}

const response = await axios.get(request.query.url);
const mime: string | undefined =
response.headers['content-type']?.toString();
Expand Down

0 comments on commit f241a46

Please sign in to comment.