Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Why does UI5 tooling serve a directory index? #623

Open
piejanssens opened this issue May 25, 2022 · 5 comments
Open

Why does UI5 tooling serve a directory index? #623

piejanssens opened this issue May 25, 2022 · 5 comments
Labels
enhancement New feature or request module/ui5-server Related to the UI5 Server module

Comments

@piejanssens
Copy link

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

@svbender svbender added enhancement New feature or request module/ui5-server Related to the UI5 Server module labels May 25, 2022
@RandomByte
Copy link
Member

Looks like a duplicate of #579?

@piejanssens
Copy link
Author

[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
Copy link
Member

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
Copy link
Author

piejanssens commented May 27, 2022

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
Copy link

vobu commented May 30, 2022

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request module/ui5-server Related to the UI5 Server module
Projects
None yet
Development

No branches or pull requests

4 participants