Skip to content

Commit

Permalink
fix:404 Worker threw exception
Browse files Browse the repository at this point in the history
  • Loading branch information
x-dr committed Aug 24, 2023
1 parent 4650f30 commit d252c0e
Showing 1 changed file with 6 additions and 1 deletion.
7 changes: 6 additions & 1 deletion functions/[id].js
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,12 @@ export async function onRequestGet(context) {
const Url = await env.DB.prepare(`SELECT url FROM links where slug = '${slug}'`).first()

if (!Url) {
return Response.status(404).json({ message: 'Not Found.' })
return new Response("404 Not Found", {
status: 404,
headers: {
"content-type": "text/html;charset=UTF-8",
}
});
} else {
try {
const info = await env.DB.prepare(`INSERT INTO logs (url, slug, ip,referer, ua, create_time)
Expand Down

0 comments on commit d252c0e

Please sign in to comment.