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.

What am I doing wrong?

See original GitHub issue

I have a gulp task that uses webpack to package up my client-side code and puts it into the file [app_root]/build/public/bundle.js

My Koa server is also babel transpiled and then placed into [app_root]/build/index.js

Then I’m trying the following in my app:


import staticServe from 'koa-static'
import koa from 'koa'

let app = koa()

app.use(staticServe('public'))

And I keep getting the following error whenever I try to load my page and it tries to request the bundle.js file:

  BadRequestError: Invalid Request
  .
  .
  at Object.serve (/Users/mmarcus/WebstormProjects/Fanatics-3C/3c-middleware/node_modules/koa-static/index.js:41:14)

For the time being, I’ve gotten things to work with the following, but it’s obviously a hack and breaks koa’s handling of 404’s for requests to the /public folder, giving me TypeError: Cannot read property 'Symbol(Symbol.iterator)' of undefined

app.use(function* (next) {
  if (this.request.path.indexOf('/public') === 0) {
    yield staticServe(`${__dirname}`)
  } else {
    yield next
  }
})

Please help?

Issue Analytics

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

github_iconTop GitHub Comments

4reactions
haoxinscommented, Mar 18, 2016

Closed due to inactivity!

2reactions
RavenHursTcommented, Mar 21, 2016

Guess I’ll just tackle this myself then…

Read more comments on GitHub >

github_iconTop Results From Across the Web

I feel stuck in life, what am I doing wrong? - Quora
Coming to the point, what you are doing wrong can be best judged by you. I am feeling lonely and depressed. I am...
Read more >
Ep #142: Finding the Answer: What Am I Doing Wrong?
I'm sharing how to talk to any shame you're experiencing, and how to define success, failure, and everything in between.
Read more >
What Am I Doing Wrong? - Troubleshoot Your Dating Life for ...
Ever wonder, “What Am I Doing Wrong?” when it comes to dating and love. Find out how you can improve your dating and...
Read more >
What am I doing wrong? : r/socialskills - Reddit
What am I doing wrong ? Hello everybody. First, I just wanted to say 'hi' to ...
Read more >
"What am I doing wrong in my relationship": 13 most common ...
“What am I doing wrong in my relationship”: 13 most common mistakes. We sometimes include products we think are useful for our readers....
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