digitallyinduced/ihp

Can't redirect to remote server

Opened this issue · 2 comments

I was trying to see if I can redirect to a controller, and add a hash. So I tried this function:

redirectToUrl "https://github.com/digitallyinduced/ihp?query=1#hash=2"

But this results with an error - likely because we are trying to Ajax it.

image

You can use formForWithoutJavascript (https://ihp.digitallyinduced.com/Guide/form.html#disable-form-submission-via-javascript) to workaround this issue (assuming you have a form)

I think that won't work in all cases. Silly example:

A user has to enter a URL in the field, and when submitted, we will redirect there. Before submit, we still don't know if there's CORS enabled on that URL.

What this PR does is try to fetch it via JS. If it fails, instead of returning an error, it does a full page refresh for the redirect.