我有一个新手问题。我有一个Flash的Facebook应用程序,它使用Facebook信用。我使用express框架来服务我的静态html文件,其中包含application.swf。express.static无法响应POST请求
这是我如何配置快递:
var app = express();
app.configure(function(){
app.use(express.methodOverride());
app.use(express.bodyParser());
app.use(express.logger());
app.use(app.router);
// Redirections for default pages
app.all("/", function(req, res) { res.redirect("/index.html"); });
app.all("/facebook", function(req, res) { res.redirect("/facebook/index.html"); });
// Serve static files
app.all("*", express.static('/my/static/files/directory'));
app.use(express.errorHandler({
dumpExceptions: true,
showStack: true
}));
});
require('http').createServer(app).listen(80);
require('https').createServer({
key: fs.readFileSync('./certs/www.app.org/www.app.org.key'),
cert: fs.readFileSync('./certs/www.app.org/www_app_org.crt'),
ca: fs.readFileSync('./certs/www.app.org/www_app_org.ca-bundle'),
}, app).listen(443);
我用这个结构来服务于HTTP和HTTPS请求我的应用程序。 当传入的http请求类型为GET时,它工作正常。
但是,当用户在应用程序中购买物品时,脸书向我的应用程序发送POST请求。 问题是当接收POST请求到静态文件目录时,表达式抛出404错误。
P.S. :POST请求发送到相同的URL,这对GET请求非常有效。
这里是监测结果:
node_local:httpserver 88.250.59.159 - - [Fri, 17 Aug 2012 11:51:09 GMT] "POST /facebook/index.html HTTP/1.1" 404 - "-" "Apache-HttpClient/4.1.3 (java 1.5)"
node_local:httpserver 88.250.59.159 - - [Fri, 17 Aug 2012 11:50:59 GMT] "GET /facebook/index.html HTTP/1.1" 200 5892 "-" "Apache-HttpClient/4.1.3 (java 1.5)"
完美合理,并且效果很好... – 2012-08-17 12:40:15
我也测试过它,它工作的很棒。 – Nadjib 2014-08-14 21:59:17