SAP / ui5-tooling

An open and modular toolchain to develop state of the art applications based on the UI5 framework
https://sap.github.io/ui5-tooling
Apache License 2.0
466 stars 69 forks source link

Why does UI5 tooling serve a directory index? #623

Open piejanssens opened 2 years ago

piejanssens commented 2 years ago

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 ☺️

RandomByte commented 2 years ago

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

piejanssens commented 2 years ago

[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/.

RandomByte commented 2 years ago

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)?

piejanssens commented 2 years ago

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.

vobu commented 2 years ago

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