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 8311981
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 8, 20262026-06-08T20:00:08+00:00 2026-06-08T20:00:08+00:00

I’m so sure that I made some silly error somewhere in my app, but

  • 0

I’m so sure that I made some silly error somewhere in my app, but I just can’t seem to find it.

So here’s what my Express app looks like. I have my routes set up as such:

var routes = require('./routes');
...
app.get('/', routes.index);
app.get('/embed', routes.embed);
app.post('/upload', routes.upload);

In my routes folder, I have two files. The index.js file exports the two request handlers .index and .embed. It might be helpful to know that .embed creates a CSRF token to be used on the /embed page:

exports.embed = function(req, res){
  var csrf = req.session._csrf;
  res.render('embed', { token: csrf });
};


form#secret-form(name="secret-form", method="post", action="/upload", style="")
  input(type="hidden", name="_csrf", value="#{token}")
  input(type="hidden", name="image")
  input#send-button(type="submit") Upload

Just a brief note if it’s causing the issue: I did attach a .submit jQuery handler to this form; it simply grabs the data URL from a canvas object on this page, and puts that as the value to the input field with the name “image”.

The .upload route is handled in the routes/upload.js file. It looks something like this:

exports.upload = function(req, res) {
  console.log("Receiving upload...");
  var imageURL = req.body.image;
  // snippet of code that grabs a canvas data URL and stores it in a file
};

I don’t think the contents of this function matters because I get the following log output for requests going to /upload from the /embed form. It doesn’t even print the “Receiving upload…” line; it simply returns a page that says “Cannot POST /upload”:

127.0.0.1 - - [Thu, 26 Jul 2012 04:07:41 GMT] "POST /upload HTTP/1.1" 404 - "http://0.0.0.0:3000/embed"

So, what can I possibly be doing wrong here? Is it my app configuration? I suspect it might be so since the POST requests stopped working after I added CSRF support. But now I’m just speculating…

app.configure(function(){
  app.set('views', __dirname + '/views');
  app.set('view engine', 'jade');
  app.use(express.bodyParser());
  app.use(express.methodOverride());
  //app.use(express.limit('1mb'));
  app.use(express.query());
  app.use(express.logger());

  // CSRF stuff
  app.use(express.cookieParser());
  app.use(express.session({ secret: "secret", cookie: { maxAge: 60000 } }));
  app.use(express.csrf());

  app.use(app.router);
  app.use(express.static(__dirname + '/public'));
});
  • 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-06-08T20:00:11+00:00Added an answer on June 8, 2026 at 8:00 pm

    Your index.js file should look something like this so that routes.upload actually refers to the upload export of upload.js:

    exports.upload = require('./upload').upload;
    
    exports.index = function(...
    
    exports.embed = function(...
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have just tried to save a simple *.rtf file with some websites and
I have a French site that I want to parse, but am running into
I'm parsing an RSS feed that has an ’ in it. SimpleXML turns this
Seemingly simple, but I cannot find anything relevant on the web. What is the
That's pretty much it. I'm using Nokogiri to scrape a web page what has
link Im having trouble converting the html entites into html characters, (&# 8217;) i
I want to count how many characters a certain string has in PHP, but
For some reason, after submitting a string like this Jack’s Spindle from a text
I have a jquery bug and I've been looking for hours now, I can't
I've got a string that has curly quotes in it. I'd like to replace

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.