我试图在parse.com上托管angularjs SPA 我暂时没有上传任何服务器代码(他们只是静态文件!) https://app.hybridrecruitment.com
以下链接有效:https://app.hybridrecruitment.com/#/pages/auth/register 虽然https://app.hybridrecruitment.com/pages/auth/register将返回找不到的页面。
您能否就云端代码提供相应的建议.htaccess?
<IfModule mod_rewrite.c>
RewriteEngine On
# Send all requests to the index.html unless
# it's a directory or a file that actually exists
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^ index.html [L]
</IfModule>
答案 0 :(得分:0)
自己找到解决方案。不知道它是否最符合逻辑。但它的确有效。 基本上每次请求我都会抓住并提供index.html。
var express = require('express');
var app = express();
//push state interceptors
var pushUrlPrefixes = [""];
var index = null;
function getIndex(cb) {
return function(req, res) {
Parse.Cloud.httpRequest({
url: 'my_url_here', // works only in http
success: function(httpResponse) {
index = httpResponse.text;
cb(req, res);
},
error: function(httpResponse) {
console.log('error');
console.log(httpResponse);
res.send("We're very busy at the moment, try again soon:"+httpResponse.text);
}
});
}
}
pushUrlPrefixes.forEach(function(path) {
app.get("/"+path+"*", getIndex(function(req, res) {
res.set('Content-Type', 'text/html');
res.status(200).send(index);
}));
});