Skip to content

Commit

Permalink
stats: try to fix reading pixel.gif, take 2
Browse files Browse the repository at this point in the history
  • Loading branch information
mimecuvalo committed Mar 3, 2023
1 parent 3aa20b7 commit b7147d6
Showing 1 changed file with 3 additions and 5 deletions.
8 changes: 3 additions & 5 deletions pages/api/stats.ts
Original file line number Diff line number Diff line change
@@ -1,12 +1,10 @@
import { NextApiRequest, NextApiResponse } from 'next';

import fs from 'fs';
import { isRobotViewing } from 'util/crawler';
import { parseContentUrl } from 'util/url-factory';
import path from 'path';

const filePath = path.resolve(process.cwd(), 'public/img/pixel.gif');
const pixelImageBuffer = fs.readFileSync(filePath);
const buf = new Buffer(43);
buf.write('R0lGODlhAQABAIAAAAAAAAAAACH5BAEAAAAALAAAAAABAAEAAAICRAEAOw==', 'base64');

export default async function handler(req: NextApiRequest, res: NextApiResponse) {
const { username, name } = parseContentUrl(req.query['resource'] as string);
Expand All @@ -29,5 +27,5 @@ export default async function handler(req: NextApiRequest, res: NextApiResponse)
});

res.setHeader('Content-Type', 'image/gif');
res.send(pixelImageBuffer);
res.send(buf);
}

1 comment on commit b7147d6

@vercel
Copy link

@vercel vercel bot commented on b7147d6 Mar 3, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please sign in to comment.