Skip to content

Release v2.2.1 is creating a lot of server entries #167

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

Closed
ssrini opened this issue Oct 21, 2019 · 9 comments · Fixed by #168
Closed

Release v2.2.1 is creating a lot of server entries #167

ssrini opened this issue Oct 21, 2019 · 9 comments · Fixed by #168
Assignees
Labels
bug Something isn't working

Comments

@ssrini
Copy link

ssrini commented Oct 21, 2019

When the app is loaded, a huge number of servers are being created automatically in the localstorage. Not sure why this is so. Even if localstorage is cleared and reloaded the entries are created again.

Note: This does not happen in incognito mode

image

image

@ssrini ssrini added the bug Something isn't working label Oct 21, 2019
@acelaya
Copy link
Member

acelaya commented Oct 21, 2019

I'm going to assume you are either serving shlink-web-client using the official docker image, or you are just using the instance under https://app.shlink.io (which is also using the docker image). Let me know if that's not the case.

Shlink-web-client has two features that seem to be conflicting:

On the one hand, there's a feature which lets you serve a default list of servers under the /servers.json path, which are used precisely when the list of servers is empty (so basically, it loads the first time you open the app, and then you can modify it at will). If that path returns a 404, shlink-web-client ignores it and you start with an empty list.

On the other hand, since the app has a client-side HTML5 router, it makes sure paths the server does not know, fall back to the index.html file, instead of resulting in a 404 error. Otherwise, paths like /servers/create or /tags would fail when reloading the page.

However, there are some known extensions which are still handled as a 404 when not found. Mostly known static file extensions, like css, js and such. The list is long, but it is currently missing json, which is probably what's making the /servers.json path to return the index.html file, which is in turn treated as an array, therefore, splitting every character as if it was a server. That creates a lot of servers.

The fix is easy, the json extension just needs to be added in this nginx rule

However, I'm confused, because regardless the fact that the issue seems pretty clear, I'm not being able to reproduce it.

Can you check if /servers.json (either under your domain or under https://app.shlink.io/servers.json) is returning the index.html file for you or an nginx's 404 error? Because for me, it returns the 404, which would be the correct behavior, but I think it might be a caching thing.

Which one of these do you see?

image

image

@acelaya
Copy link
Member

acelaya commented Oct 21, 2019

I'm still not sure how did you get to that situation, but I have just pushed a fix which should cover your case.

It adds the json extension in the nginx config file, but it also makes sure that, if the content of /servers.json is not a json array, it is ignored.

It will cover those cases in which this file includes malformed or invalid content, for example, but also the case in which, for some reason, it falls back to the index.html.

It is now building. I will let you know when it's available as v2.2.2

@acelaya acelaya self-assigned this Oct 21, 2019
@acelaya
Copy link
Member

acelaya commented Oct 21, 2019

@ssrini the new version is already available if you want to grab it, and it has been deployed in app.shlink.io

@ssrini
Copy link
Author

ssrini commented Oct 22, 2019

Thanks @acelaya You are right .. the problem is not there after I cleared out the browser cache completely. I am using my own install behind Nginx. I think initially the config was not right and must have been returning index.html instead of a 404. I checked now and its correctly returning a 404 and after cache clear there is no issue. The hin of course was it was working in incognito :)

BTW: A note on CORS to use this app with the shlink backend in documentation will help. I had to rejig nginx config quite a bit before I got it running!

Thanks for the quick improvement

@acelaya
Copy link
Member

acelaya commented Oct 22, 2019

Awesome. I'm glad to know it works now :)

Regarding CORS, what problems did you face and how did you solve them? In theory it should work pretty much out of the box. Maybe you are facing a use case I didn't consider.

@ssrini
Copy link
Author

ssrini commented Oct 22, 2019

Nothing. I had missed the CORS requirement completely since docs dont seem to mention it (or I might have missed it). Also sample configs for nginx etc might help users. Nothing else.

@acelaya
Copy link
Member

acelaya commented Oct 22, 2019

It is actually documented https://shlink.io/api-docs/ :)

Maybe it should be mentioned in some README file too. It's hard to keep the website and README files in sync.

Regarding nginx config, I guess you mean for the web client? For the server there's examples too, both in the website and the readme.

@ssrini
Copy link
Author

ssrini commented Oct 22, 2019

Actually when I tried connecting to my API from app.shlink.io didn't work. I then had to add CORS config byvtrial and error to nginx for my API server. Then it worked.

Is the API supposed to send CORS automatically?

@acelaya
Copy link
Member

acelaya commented Oct 22, 2019

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants