-
Notifications
You must be signed in to change notification settings - Fork 1.3k
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
Url of (my) Express.js server is changing everyday #4840
Comments
Could you share your repo? Do you start with port 0? If it is in regards to host, then each new workspace gets a new host. If you want to have a stable then use localhost via the Gitpod Local Companion: https://www.gitpod.io/blog/local-app If it is because of port then you should settle on some port instead of using random. |
@akosyakov, It's not specific to one repo. This has been happening from when I started using gitpod (a month or 2 ago) For example: my back-end (express) server is running on https://.us08..com, after some time (I think days) it automatically becomes, https://<same_stuff>.us09.<same_stuff>.com I can't change the base URL of the API calls (to the server) I make from the client all the time. It should be static. |
You should use https://www.gitpod.io/blog/local-app if you want to have stable URLs. Alternatively you rewrite the code that it computes a request from window.location.href. The second will be more appropriate approach it let you deploy your app under different host without changing the code. |
@akosyakov will that work even if the URL of my server is changing? |
Which approach do you mean? It would be the best if you can share code of your client. |
@akosyakov It's happening to all my repos. I make API calls using Axios, I specify the baseUrl as the URL of my back-end(express) server, so when it changes automatically, the API calls get affected too (because the baseUrl is changing and becomes invalid) |
A sample workspace of mine (as @akosyakov asked): https://sapphire-quokka-1i5clgk7.ws-us11.gitpod.io/?folder=vscode-remote%3A%2F%2Fsapphire-quokka-1i5clgk7.ws-us09.gitpod.io%3A443%2Fworkspace |
sorry, I don't understand. I meant I would like to see a code of the client which how do you do a request. Is it a part of the same project? |
@akosyakov I don't think u would need the code, if u read the comment I made before I sent that link, you'd understand what I am talking about |
Whenever you create a new workspace you get a new URL, if there is a new version of Gitpod deployed URL also can change. Gitpod does not guarantee stability of URLs. You can achieve it by using Gitpod Local Companion and accessing via localhost or if a client code is served from the same workspace then you can analyze |
@akosyakov, that sounds about right, but I can only try it after 2 hours. Thanks for your help so far |
@akosyakov, I am making the question clear to you (one more time, in case u don't understand) Say for example, I am starting a express.js server, it is running on port 5000, and it is hosted in a URL provided by gitpod. I call/request the server (API) from Postman (API tester) now, after sometime (days) when I make the same call (say GET request) the server isn't responding, because the URL of the host has been changed (automatically). I don't want that to happen, and I will check if the solutions provided by you fix this. P.S - I sent this as an alternative to the previous client-side approach |
@Kaushik-Kalesh sorry I don't know working of Postman. If it is installed locally you should be able just use the local companion, if it is SaaS service, maybe it allows configuration similar to https://auth0.com/docs/applications/work-with-auth0-locally#use-local-domains-with-auth0 in this case you can use the local companion as well. Having stable workspace URLs is hard problem, and we don't see ways generally stabilize them right now. |
duplicate of #898 |
@akosyakov ok thank you |
Bug description
When I was working on a MERN stack project, I noticed (some part of) the url of the Express.js (back-end server) was changing everyday.
Steps to reproduce
Try hosting a server, and check if (some part of it) changes.
Expected behavior
I want a static url for my servers.
Example repository
No response
Anything else?
No response
The text was updated successfully, but these errors were encountered: