ui5-tooling icon indicating copy to clipboard operation
ui5-tooling copied to clipboard

Why does UI5 tooling serve a directory index?

Open piejanssens opened this issue 2 years ago • 5 comments

We are so used to getting index.html served over any other file (if present) when requesting '/'. What is the reasoning for requiring an explicit request to index.html? After a couple of years using UI5 Tooling, it only annoys me to have to type out the index file and I have never had any use for the directory index page.

If open to the change, this might be a good one for #506 ☺️

piejanssens avatar May 25 '22 04:05 piejanssens

Looks like a duplicate of https://github.com/SAP/ui5-tooling/issues/579?

RandomByte avatar May 25 '22 16:05 RandomByte

[ui5-middleware-index](https://github.com/ui5-community/ui5-ecosystem-showcase/tree/main/packages/ui5-middleware-index)is a great workaround, but I created this issue to learn about or challenge the usefulness of the default directory listing , whereas it's commonly expected to serve index.html by default when requesting a directory such as /or webapp/.

  • NGINX: https://nginx.org/en/docs/http/ngx_http_index_module.html#index
  • Apache: https://cwiki.apache.org/confluence/display/httpd/DirectoryListings
  • Express: You could use the built-in express-static API, see index using default ìndex.html`

piejanssens avatar May 25 '22 17:05 piejanssens

We saw value in having a directory listing so we added it to ui5-server. We discussed adding an exception for index.* files but never went through with it. Then we added the --open CLI option which allowed you to put things like ui5 serve --open index.html into your package.json. This solved the immediate need for adapting the index listing middleware for us. Later, the community middleware was created and basically no one requested this anymore.

But I see where you are coming from since it indeed seems to be common practice for many web servers.

I think adding a ui5.yaml configuration is simple enough. The serveIndex middleware could then redirect requests for directories which contain one or more files matching with a ranked list of "index" files. Redirecting requests (i.e. "HTTP303 See Other") might be better imho, to make sure developers are always working with the full resource-URL (including the resource name). E.g. http://localhost:8080/ gets redirected to http://localhost:8080/index.html instead of serving the file directly.

We must not forget that ui5-server is a development server. We can't assume how the deployment server works. So we should not add too much magic 🪄

What do you think? Would a project configuration be helpful here or do you see a need to change the default behavior (too)?

RandomByte avatar May 27 '22 15:05 RandomByte

Personally, I don't see any value in the directory listing.

I know ui5 serve is only for development purposes, but still, it would be nice to remove the explicit index.html resource request or a community middleware. It simplifies things...

I would change the default behavior as this will not impact bookmarks, CI or --open.

P.S. - On production: @sap/approuter does automatically serve index.html on request to a directory.

piejanssens avatar May 27 '22 15:05 piejanssens

https://github.com/ui5-community/ui5-ecosystem-showcase/tree/main/packages/ui5-middleware-index 😼

vobu avatar May 30 '22 08:05 vobu