I am using sails to serve an ember.js app, which works all really great, apart from using thr history API feature (explained here: http://emberjs.com/api/classes/Ember.Location.html#sts=HistoryLocation)
One simple solution would be, to have all routes that are defined in Ember also defined in the sails app and let them just serve the index.html. Ember should figure out the rest.
I would imagine something like:
'/route': {
static: 'index.html'
}
in the routes.js. Is this currently somehow possible?
@Globegitter , I use sails.js with ember.js in my project the https://github.com/wejs/we
Today sending the initial page for all requests and load the preprocessed templates handlebars in format. Js
The data are accessed by the prefix / api/v1 / ....
See https://github.com/wejs/we/blob/master/api/policies/AllRoutesPolicy.js
and https://github.com/wejs/we/blob/master/api/responses/notFound.js
needs some improvements but is working
Hi @Globegitter, thanks for using Sails! FYI, we try to keep this forum restricted to bug reports and feature requests, to keep the support load for the core team manageable. For implementation help, check out our Google Group or the IRC channel at irc://irc.freenode.org/sailsjs, or post a question on Stackoverflow.
In answer to your question, your strategy seems sound. You can put a catchall route at the _bottom_ of your config/routes.js file, like:
"/*": {view: "index.ejs"}
Putting it at the bottom is important as the routes are matched in the order they appear in the file, so you could put any routes you wanted Sails to handle above it. Then give your view/index.ejs file mimic the same content as index.html, or even symlink them together, and you should be good to go.
@sgress454 Thank you for the answer, will keep more to the Google Group or Stackoverflow next time.
The subject of the issue might confuse some people... But to those people:
You can still serve static files the way you do with req.createReadStream:
var SomeAwesomeController = {
serve: function(req, res) {
fs.exists(target, function (exists) {
if (!exists) {
return res.notFound('The requested file does not exist.');
}
fs.createReadStream(target).pipe(res);
});
}
};
@RWOverdijk Thanks for that might try it out.
@sgress454 Just tried to symlink index.ejs -> assets/index.html and when I run sails lift all I get is:

Is sails not realizing that this is a symlink?
Edit: If I use a controller that serves the symlinked index.ejs Sails seems to be able to serve it, but I am getting the same error as in the message below.
@RWOverdijk Just tried out your method and it does seem to serve the index.html, but I am getting the following errors:

I assume it might just be a matter of telling Sails to serve the file differently, but not quite sure how to solve it. Any wisdom would be appreciated.
Edit: That is really strange, serving the index.html by itself works without any issue.
If I copy the contents of index.html to the index.ejs and serve it via
'/': {
view: 'index'
}
that also works, but if I change the / to /* I get the same error as above. And it makes no difference if I serve the view directly or through a Controller it seems. Very strange.
@Globegitter Sorry, I didn't notice my typo--the .ejs extension shouldn't be in the route config. It should be:
"/*": {view: "index"}
It should work fine with symlinks.
@sgress454 Oh yeah, that was a copy & paste error that I missed as well, but now I am still getting the error in the post above. With unexpected token, etc.
And as I said this is just by the mere fact that I am changing / to /* it seems.
@sgress454 any more thoughts? Could that be a bug, or just something I am getting wrong somehow?
I think I might just be misunderstanding what exactly you're trying to do, but it does occur to me that the catchall route will also catch static assets unless you tell it not to:
"/*": {view: "index", skipAssets: true}
That's likely what's causing the errors in your JS console; it's sending the view file for every static asset request.
Most helpful comment
The subject of the issue might confuse some people... But to those people:
You can still serve static files the way you do with
req.createReadStream: