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.

ReferenceError: req is not defined

See original GitHub issue

wrangler pages dev --proxy 8090 -- astro dev --verbose results in

[HPM] Proxy created: /  -> http://127.0.0.1:40527
[HPM] Proxy created: /  -> http://127.0.0.1:8090
Serving at http://127.0.0.1:8788/
/blog/node_modules/wrangler/wrangler-dist/index_node.js:27064
            throw ex;
            ^

[UnhandledPromiseRejection: This error originated either by throwing inside of an async function without a catch block, or by rejecting a promise which was not handled with .catch(). The promise rejected with the reason "ReferenceError: req is not defined".] {
  code: 'ERR_UNHANDLED_REJECTION'
}

Running:

      "resolved": "https://registry.npmjs.org/wrangler/-/wrangler-0.0.0-fsw-beta.5.tgz",

(inside docker nodejs container)

and for _worker.js

export default {
  async fetch(request, env) {
    if (req.url.startsWith('/api/')) {
      // TODO: Custom /api/* Worker logic
      return new Response('TODO: add logic')
    }

    // Otherwise, serve static asset(s).
    // Without this, Worker will error and no assets will be served.
    return env.ASSETS.fetch(request)
  }
}```

Issue Analytics

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

github_iconTop GitHub Comments

1reaction
threepointonecommented, Nov 21, 2021

(we should still do a better job of showing that error outside of the Promise rejection)

0reactions
WalshyDevcommented, Nov 21, 2021

Yeah, I saw haha. Too quick for me

Read more comments on GitHub >

github_iconTop Results From Across the Web

Node "req is not defined" - Stack Overflow
You probably mismatched the frameworks. Pure HTTP has request in handler specified in createServer. req is specific for the Express framework.
Read more >
req is not defined in NodeJS application - dark-hamster
How to Solve Error Message ReferenceError: req is not defined in NodeJS application ... Actually, it is a part for returning a value...
Read more >
Newbie help: ReferenceError: req is not defined : r/node - Reddit
Hi guys! I am not sure how to get this solved, I have gone through Stackoverflow and some other resources, most of them...
Read more >
ReferenceError: request is not defined (Example) - Treehouse
Has anyone encountered the error 'ReferenceError: request is not defined' when trying to follow the get method example?
Read more >
Node.js req.query Not Defined in PhpStorm
ReferenceError : req is not defined at Object.<anonymous> (C:\Users\me\PhpstormProjects\myprojectname\index.js:4:13) at Module.
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