Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7403441
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 29, 20262026-05-29T05:04:57+00:00 2026-05-29T05:04:57+00:00

I’m starting to get things set up using flatiron as the toolset for a

  • 0

I’m starting to get things set up using flatiron as the toolset for a web app.

I’m using director with app.plugins.http, and can’t seem to figure out how to create a “catchall” route for static files & 404s – It appears that .get("<RegEx>") only matches the first folder position, so if <RegEx> is /.*, it’ll match /foo, but not /foo/bar.

Here’s my code, as a better example:

in routes.js:

var routes = {
  /* home
  * This is the main route, hit by queries to "/"
  */
  "/" : {
    get: function(){
      getStatic("html/index.html",_.bind(function(err,content){
        if(err) throw err;
        renderContent(this,content);
      },this));
    }
  },
  /* static files
  * Last rule, if no other routes are hit, it's either a static resource
  * or a 404. Check for the file then return 404 if it doesn't exist.
  */
  '/(.*)' : {
    get : function(){
      getStatic(this.req.url,_.bind(function(err,content){
        if(!err){
          renderContent(this,content);
        } else {
          this.res.writeHead(404);
          // TODO: fancier 404 page (blank currently)
          this.res.end();
        }
      },this))
    }
  }
}

and in my main app file:

/* Define the routes this app will respond to. */
var routes = require('./lib/routes');
/* set up app to use the flatiron http plugin */
app.use(flatiron.plugins.http);
/* loop through routes and add ad-hoc routes for each one */
for(var r in routes){
    var route = routes[r];
    if(!routes.hasOwnProperty(r)) continue;
    for(var method in route){
        if(!route.hasOwnProperty(method)) continue;
        app.router[method](r,route[method]);
    }
}
/* Start the server */
app.listen(8080);

I’d like to be able to keep my routes in a separate module and import them – I’m pretty unclear on if this method or using director and a vanilla http server would be better, but I’ve tried both ways without any luck.

Here’s what I get:

localhost:8080/
>> (content of index file - this works)
localhost:8080/foo
>> (blank page, 404 header)
localhost:8080/foo/bar
>> (no static file for this - I get a 404 header, but the body is now "undefined" - where is this coming from??)
localhost:8080/css/min.css
>> (this file should exist, but the route is never called. I do however still get a 404 header, and get the "undefined" body)

so, I’m assuming the “undefined” body is default behavior for undefined routes.

Is there a way to create a catchall route without adding rules for each depth?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-29T05:04:57+00:00Added an answer on May 29, 2026 at 5:04 am

    You could try using node-ecstatic which is a static file serving add-on for flatiron. It works well for me and you can find it at:

    https://github.com/colinf/node-ecstatic

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

That's pretty much it. I'm using Nokogiri to scrape a web page what has
We're building an app, our first using Rails 3, and we're having to build
I am using Paperclip to handle profile photo uploads in my app. They upload
link Im having trouble converting the html entites into html characters, (&# 8217;) i
I have a jquery bug and I've been looking for hours now, I can't
Seemingly simple, but I cannot find anything relevant on the web. What is the
I'm using v2.0 of ClassTextile.php, with the following call: $testimonial_text = $textile->TextileRestricted($_POST['testimonial']); ... and
I'm parsing an RSS feed that has an &#8217; in it. SimpleXML turns this
We are using XSLT to translate a RIXML file to XML. Our RIXML contains
Does anyone know how can I replace this 2 symbol below from the string

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.