if api domain is different from app domain then urls will be wrong
djay opened this issue · 1 comments
Describe the bug
RESTApi currently assumes that all urls are on the same domain as the api endpoint and are treated as a local url if the url starts with the plone portal url. This applies to GET and POST. So if you have slate blocks with urls and save them, then these will only get turned into resolveUID links internally in the RESTAPI if the url matches the api url.
However Volto lets you have a different api url from the frontend url but it doesn't translate urls inside blocks into urls relative the portal root of the api url. Volto will pass the url as the full url based on the frontend url where the editing happens.
If you edit on a different url to the api url these links will be treated as external and the consequences are:
- if the edit url is different to the frontend url the links will appear as the edit url and lead users to the wrong site
- if the frontend url changes then the links will be broken
- if the content moves then unneeded redirects will happen instead of direct links to the new location
- deletion of linked content warnings won't occur
- any other consequence of not having a resolveUID url.
To Reproduce
- serve your frontend on two domains
- make a slate link to another page
- view this on the via the other domain
- the url will take you to the edit domain
Expected behavior
This will be a local link
-
Volto should translate all urls to the api url before save. A reverse of the flattenToAppUrl translation.
- Api.formatUrl(path) doesn't appear to be used anywhere currently to do this job
-
Other solutions considered
- RESTApi should accept relative urls and Volto should use those instead.
- RESTApi has a list of url prefixes it should treat as internal
Screenshots
If applicable, add screenshots to help explain your problem.
Software (please complete the following information):
- OS: [e.g. iOS]
- Browser [e.g. chrome, safari]
- Volto Version [e.g. 8.5.0]
- Plone Version [e.g. 5.2.2]
- Plone REST API Version [e.g. 7.0.1]
Additional context
Add any other context about the problem here.
tips on where the best place to patch this would be appreciated.