I am using ring's resource handler (ring/create-resource-handler) to serve a Vite application. Vite builds the application as index.html and other files in the same distribution directory. I rely on the resource handler's support for index files to serve this application. However, the resource handler's index files support doesn't work quite like I expect or would like.
When I request /, this handler responds with an HTTP 302 redirect to /index.html. This results in an undesired customer-visible URL. I want index.html to be an implementation detail, and for the resource handler to serve the content of index.html in response to GET / without a redirect. This would be consistent with how Apache httpd's mod_dir works; see default for DirectoryIndexRedirect directive.
Can you suggest how I can achieve the desired behavior of serving index.html transparently on GET /?
Some options I see:
Create a custom route for just /index.html that serves my file directly, with the existing resource handler as a fallback for other routes. I imagine then I'd need to disable conflict resolution, which doesn't sound good.
Add a configuration parameter to the ring resource handler to support the equivalent of apache httpd's DirectoryIndexRedirect options. Do you think this would be a good idea?
I am using ring's resource handler (
ring/create-resource-handler
) to serve a Vite application. Vite builds the application asindex.html
and other files in the same distribution directory. I rely on the resource handler's support for index files to serve this application. However, the resource handler's index files support doesn't work quite like I expect or would like.When I request
/
, this handler responds with an HTTP 302 redirect to/index.html
. This results in an undesired customer-visible URL. I wantindex.html
to be an implementation detail, and for the resource handler to serve the content ofindex.html
in response toGET /
without a redirect. This would be consistent with how Apache httpd'smod_dir
works; see default forDirectoryIndexRedirect
directive.Can you suggest how I can achieve the desired behavior of serving
index.html
transparently onGET /
?Some options I see:
/index.html
that serves my file directly, with the existing resource handler as a fallback for other routes. I imagine then I'd need to disable conflict resolution, which doesn't sound good.DirectoryIndexRedirect
options. Do you think this would be a good idea?