grist-core icon indicating copy to clipboard operation
grist-core copied to clipboard

Custom Widgets − TypeError: Only absolute URLs are supported

Open jperon opened this issue 2 years ago • 2 comments

While installing a new instance of Grist, I get this error when I access the right menu of custom widgets; and the only choice I get is Custom URL. I get this in the logs:

grist_1  | 2023-11-28 06:03:07.828 - debug: Auth[GET]: db.EXAMPLE.COM /widgets customHostSession=, method=GET, host=db.EXAMPLE.COM, path=/widgets, org=MYORG, [email protected], userId=6, altSessionId=undefined
grist_1  | 2023-11-28 06:03:07.829 - warn: Error during api call to /widgets: TypeError: Only absolute URLs are supported path=/widgets, userId=6, altSessionId=undefined, , 
nginx    | 10.35.35.127 - - [28/Nov/2023:06:03:07 +0000] "GET /o/MYORG/api/widgets HTTP/2.0" 500 55 "https://db.EXAMPLE.COM/6jGL1rpTHses/cole/p/93" "Mozilla/5.0 (X11; Linux x86_64; rv:109.0) Gecko/20100101 Firefox/114.0"
grist_1  | 2023-11-28 06:03:07.830 db.EXAMPLE.COM GET /o/MYORG/api/widgets 500 4.193 ms - 55
grist_1  | 2023-11-28 06:03:07.875 - debug: Auth[POST]: db.EXAMPLE.COM /log customHostSession=, method=POST, host=db.EXAMPLE.COM, path=/log, org=MYORG, [email protected], userId=6, altSessionId=undefined
grist_1  | 2023-11-28 06:03:07.875 - warn: client error fileName=https://db.EXAMPLE.COM/v/unknown/main.bundle.js, lineNumber=2, columnNumber=489307, message=Request to https://db.EXAMPLE.COM/o/MYORG/api/widgets failed with status 500: Internal Server Error (TypeError: Only absolute URLs are supported), status=500, userError=TypeError: Only absolute URLs are supported, docId=6jGL1rpTHsestxGJwJoR8S, page=https://db.EXAMPLE.COM/6jGL1rpTHses/cole/p/93, language=fr, platform=Linux x86_64, userAgent=Mozilla/5.0 (X11; Linux x86_64; rv:109.0) Gecko/20100101 Firefox/114.0, org=MYORG, [email protected], userId=6, altSessionId=undefined

I had this error previously when trying to setup a relative URL to my widgets (those being hosted on a /widgets path thanks to a nginx reverse proxy). I don’t understand why it raises here, as my settings are the same as the previous instance. The only difference is that, here, I launch Grist with a docker-compose file instead of a script calling docker; but I mounted the same volumes on the same places, with same environment variables.

In first place, my question would be: is there a reason to enforce absolute URLS for custom widgets ?

jperon avatar Nov 28 '23 06:11 jperon

The reason is concern for the scenario where a document is moved from one installation of Grist to another. However, I added the new restriction with plugins in mind, to make sure relative URLs to them didn't leak - I wasn't thinking of your setup. Perhaps the restriction should be undone so as not to break existing setups.

paulfitz avatar Dec 01 '23 14:12 paulfitz

It would certainly be easier in my case if relative URLS where allowed. This issue, along with #726, has made it a bit harder for some of my widgets.

Just my two cents, but perhaps adding a warning when the user selects Custom URL, saying that this option might restrict portability, would be enough to avoid unwanted consequences? It’s a fact anyway that it does: if the URL is on the web, it makes the widget unusable offline.

jperon avatar Dec 01 '23 15:12 jperon