I have been researching this for quite a while and it seems that I cannot get my head around it. I have different ideas but all of them looks like they are not the right one to solve this problem.
I have an application in flask that does different things like for example:
- loading an image (user profile image)
- calling APIs (to perform specific tasks, like for example adding a comment to a forum post)
- etc.
The way I am doing all of this is by using url_for in this way:
client_info = requests.post(url_for('api.read_comments', _external=True),
json={'client_name': client}).json()
So my application is at "https://www.myapp.com/comments" - The "url_for()" in my code will basically generate this url: "https://www.myapp.com/api/read_comments". All comments are then retrieved by my API code.
This works just fine, but what I would like to do is to have the Frontend on "https://www.myapp.com/" but the Backend on "https://backend.myapp.com".
So my question is, how can I make my url_for() as dynamic as possible and able to access content on other subdomains/servers that I own?
Any thoughts? Or additional methods/functions that I should be using? For example all comments will be located at "comments.myapp.com", all my profile details are on "profiles.myapp.com", etc. This is just a general idea on how the system can be setup. Any thoughts?
Thanks a lot and I look forward to hearing from you.