Open ad-si opened 6 years ago
Care to share your project.yml
and templates?
This is a peculiar situation: the /
route produces a JSON response, and the -bake
command handles these by simply dumping the JSON output into the file that corresponds to the route.
The problem here, however, is that since we're processing the root URL, that file amounts to ./baked
, which is a directory, so we can't write our JSON data into that.
This is actually a more general problem though; if, for example, you were to have, say, the following routes:
{ pattern: '/foo', data: { ... } }
{ pattern: '/foo/bar', data: { ... } }
Note that both routes default to producing JSON output, so the -bake
command would have to create the following two files:
./baked/foo
./baked/foo/bar
But that would require ./baked/foo
to be a directory in the second case, and a file in the first case.
It works for HTML responses, because these are handled differently: if we add templates to those routes so that they render HTML, we get the following files:
./baked/foo/index.html
./baked/foo/bar/index.html
Now ./baked/foo
is a directory in both cases, and everything works.
We could do the same for JSON responses, probably, but then we'd have to add a suitable additional default document to the .htaccess
configuration (and thus we would be hardcoding the Apache dependency even harder than we already do).
For now, I think the best workaround is to just not have JSON routes that collide with directories; an approach that works well for anything other than /
is to append .json
to the route (which has the additional advantage that idiotic browsers like certain versions of IE, that have broken MIME type detection in some edge cases, will handle them correctly).