title: Can I have koa-static serve assets at a custom (e.g., /static/) path?
body: <p>The docs at <a href="https://github.com/koajs/static" rel="noreferrer">https://github.com/koajs/static</a> and my personal experience trying out koa-static lead me to believe that you can <strong>only</strong> serve files from the root URL of your app.</p>
  
  <p>For example:</p>
  
  <pre><code>app.use(serve('./some/dir/'));
  </code></pre>
  
  <p>Given the above use of <code>serve</code>, the URL to access a file <code>./some/dir/something.txt</code> would be <code>localhost:3000/something.txt</code>. There doesn't seem to be a way to configure my app such that the same file (and all other files in the same dir) is served at <code>localhost:3000/static/something.txt</code> instead.</p>
  
  <p>I'm new to Node and to Koa, so I've just begun to dive into this and I'm probably missing something really obvious.</p>
  
  <h3>I tried using koa-route to achieve this:</h3>
  
  <pre><code>app.use(route.get('/static/*'), serve(__dirname + '/some/dir'));
  </code></pre>
  
  <p>But upon requesting <code>/static/something.txt</code> I was met with the following:</p>
  
  <pre><code>  TypeError: Cannot read property 'apply' of undefined
        at Object.&lt;anonymous&gt; (/Users/me/example/src/node_modules/koa-route/index.js:34:18)
        at GeneratorFunctionPrototype.next (native)
        at onFulfilled (/Users/me/example/src/node_modules/koa/node_modules/co/index.js:64:19)
        at /Users/me/example/src/node_modules/koa/node_modules/co/index.js:53:5
        at Object.co (/Users/me/example/src/node_modules/koa/node_modules/co/index.js:49:10)
        at Object.toPromise (/Users/me/example/src/node_modules/koa/node_modules/co/index.js:117:63)
        at next (/Users/me/example/src/node_modules/koa/node_modules/co/index.js:98:29)
        at onFulfilled (/Users/me/example/src/node_modules/koa/node_modules/co/index.js:68:7)
        at /Users/me/example/src/node_modules/koa/node_modules/co/index.js:53:5
        at Object.co (/Users/me/example/src/node_modules/koa/node_modules/co/index.js:49:10)
  </code></pre>