Why express any post is responsible 404?


Warning: count(): Parameter must be an array or an object that implements Countable in /home/styllloz/public_html/qa-theme/donut-theme/qa-donut-layer.php on line 274
0 like 0 dislike
13 views
I have devserver where I write front-end project.
It exists apart from the real server (omit reasons - to raise ony server-side code of the project on the LAN is not easy). To check the efficiency of interface I request express, but rather a static json jsondata folder.
GET requests work fine - I receive in response nugie data, but if I replace get to post and express returns 404, although the way ostaetsya the same. What is the reason?
Start it by task in gulp:
'use strict'; const http = require("http"); const express = require('express'); const reload = require('reload'); const path = require('path'); module.exports = function(gulp, plugins, args, config, taskTarget, server) { gulp.task('express', function() { let options = { dotfiles: 'ignore', etag: false extensions: ['htm', 'html'], index: false, maxAge: '1d', redirect: false, setHeaders: function (res, path, stat) { Res. set('x-timestamp', Date.now()) } } server.use(express.static("../web", options)); server.listen(3000) }); };
by | 13 views

2 Answers

0 like 0 dislike
Because serve-static, for reasons of common sense, only works with GET and HEAD requests.
A piece of code that will utechet quickly found directly in the index:
\rhttps://github.com/expressjs/serve-static/blob/mas...

In General it is not clear why the static contact POST verb, which is contrary to common sense really.
by
0 like 0 dislike
digging in the docks Express read that it is possible to trace requests through something like a regular season. server.post('/*')
And dashed off such a thing. It seems that, colback works and responds to post adequately.
server.post("/*", function(req, res){ Res. sendFile(path.join(__dirname, "../../web", req.url)) });
by

Related questions

0 like 0 dislike
3 answers
0 like 0 dislike
2 answers
0 like 0 dislike
2 answers
0 like 0 dislike
1 answer
110,608 questions
257,186 answers
0 comments
35,596 users