Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

TypeError: Cannot read property 'before' of undefined in static.js #83

Closed
mikl opened this issue Oct 21, 2012 · 1 comment
Closed

TypeError: Cannot read property 'before' of undefined in static.js #83

mikl opened this issue Oct 21, 2012 · 1 comment

Comments

@mikl
Copy link
Contributor

mikl commented Oct 21, 2012

I get a TypeError when I do this:

// Instantiate a Flatiron HTTP server.
var apiserver = flatiron.createApp({});

// Configure HTTP services with ecstatic for serving static files.
apiserver.use(flatiron.plugins.http, {
  before: [
    // Enable CORS via middleware.
    require('../middleware/cors'),
  ],
  // These headers are set globally.
  headers: {
    'X-Powered-By': 'Flatiron',
  },
  // Configure HTTPS if certs are specified.
  https: app.config.get('server:https'),
});

app.use(flatiron.plugins.static, {
  root: path.join(__dirname, '..', '..', 'public'),
});

Here's the full traceback:

/home/mikl/Work/Node.js/kartotekov/node_modules/flatiron/lib/flatiron/plugins/static.js:67
    app.http.before = app.http.before.concat(st(options));
                              ^
TypeError: Cannot read property 'before' of undefined
    at exports.attach.app.static (/home/mikl/Work/Node.js/kartotekov/node_modules/flatiron/lib/flatiron/plugins/static.js:67:31)
    at exports.attach (/home/mikl/Work/Node.js/kartotekov/node_modules/flatiron/lib/flatiron/plugins/static.js:80:15)
    at App.use (/home/mikl/Work/Node.js/kartotekov/node_modules/flatiron/node_modules/broadway/lib/broadway/app.js:169:31)
    at module.exports (/home/mikl/Work/Node.js/kartotekov/lib/commands/apiserver.js:36:7)
    at executeCommand (/home/mikl/Work/Node.js/kartotekov/node_modules/flatiron/lib/flatiron/plugins/cli.js:297:19)
    at Object.exports.commands.app.router.notfound (/home/mikl/Work/Node.js/kartotekov/node_modules/flatiron/lib/flatiron/plugins/cli.js:357:5)
    at Router.dispatch (/home/mikl/Work/Node.js/kartotekov/node_modules/flatiron/node_modules/director/lib/director/cli.js:50:21)
    at exports.attach.app.start (/home/mikl/Work/Node.js/kartotekov/node_modules/flatiron/lib/flatiron/plugins/cli.js:87:18)
    at onComplete (/home/mikl/Work/Node.js/kartotekov/node_modules/flatiron/node_modules/broadway/lib/broadway/app.js:86:5)
    at Object.exports.ensure (/home/mikl/Work/Node.js/kartotekov/node_modules/flatiron/node_modules/broadway/lib/broadway/features/index.js:10:10)
@mikl
Copy link
Contributor Author

mikl commented Oct 21, 2012

Ah, forget this. I am using app in place of apiserver. Reading the code works.

@mikl mikl closed this as completed Oct 21, 2012
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant