How to GET/POST files in express.static()

express, node.js

Solution

Connect, and therefore, Express, the static middleware only accepts `GET` requests. See here.

If you are trying to overwrite files in the public with a POST, you'll want to create a separate route for that.

Problem

I'm a little confused as to how Express serves files. Currently I have a `/public` directory to hold client-side resources. I configure Express using ``` app.use(express.static(__dirname + '/public')); ``` It was my impression that anything in this directory was public, and that HTTP method urls defaulted `/public` as the root directory for access (unless otherwise routed manually by Express). There is no problem using GET on any file in this directory (client-side scripts, images, ect. However, I get 404's when trying to POST files inside this directory. Do I need to manually route all POST requests ala `app.post(route, callback)` Thanks for you help

Original source