question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

I'm getting BAD_REQUEST after deploy on vercel

See original GitHub issue

What version of Next.js are you using?

10.1.3

What version of Node.js are you using?

14.15.4

What browser are you using?

Chrome

What operating system are you using?

Windows

How are you deploying your application?

Vercel

Describe the Bug

I want to take screenshot of webpage using next js that’s why i created a dynamic api. but when i request to website i get the 404 erro & BAD_REQUEST.

My screenshot path is pages/api/screenshot/[id]/index.js

My code is like this

async function api(req, res) {    
    res.send(req.query.id)
}

export default api

When i request to website i get 404 the url is like this https://next-dynamic-munnyreol.vercel.app/api/screenshot/https%3A%2F%2Fnextjs.org

I add (encodeURIComponent) url after slash screenshot https%3A%2F%2Fnextjs.org mean https://nextjs.org . . I’m getting BAD_REQUEST when i request to https://next-dynamic-munnyreol.vercel.app/api/screenshot/https%3A%2F%2

Expected Behavior

When i request to https://next-dynamic-munnyreol.vercel.app/api/screenshot/https%3A%2F%2Fnextjs.org then i want to get the value which i put after slash screenshot screenshot/ For this request, i want to get https://nextjs.org as a output

To Reproduce

The GitHub repository is https://github.com/MunnyReol/next-dynamic

Issue Analytics

  • State:closed
  • Created 2 years ago
  • Comments:8 (3 by maintainers)

github_iconTop GitHub Comments

1reaction
ljosberinncommented, May 18, 2021

Sorry it’s indeed query, but it works as expected (I’m using it in multiple sites).

export default function handler(req, res) {
  console.log(req);
  res.send(JSON.stringify(req.query));
}

image

1reaction
ljosberinncommented, May 17, 2021

This is not Next.js related but with how URLs work. Pass the url instead as GET parameter, e.g.

https://next-dynamic-munnyreol.vercel.app/api/screenshot?url=https%3A%2F%2Fnextjs.org
export default function handler(req, res) {
  if(!req.param.url || Array.isArray(req.param.url)) {
    res.status(400).end();
    return;
  }
  
  res.send(req.param.url);
}
Read more comments on GitHub >

github_iconTop Results From Across the Web

Errors – Vercel Docs
Definition: The request to a Serverless Function was not completed successfully. Occurrence: This could happen if the application contains an unhandled ...
Read more >
"Error: Bad request" when running "now" in a static site folder ...
After turning on the debug flag, I got the following log: > [debug] No manifest files found, assuming static deployment > [debug] locating ......
Read more >
Getting a 504/502 error on api requests in Nextjs deployed on ...
With some research I found out that it was happening because the server was timing out. For Vercel where I have deployed my...
Read more >
Deployed to Vercel - Getting 405s - RedwoodJS Community
Hey everyone :wave: I'm having some difficulty debugging an error in my browser console when perform a query in my Redwood app.
Read more >
Monitor Next.js API routes using Logtail | Gorrion's Blog
Set up and easily deploy the app with Vercel CLI ... Its purpose is to respond to the GET request from the app...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found