The DB response includes an authToken and a Target URL that the user should then be taken to.
The target URL will always change, and will include query string parameters. So, it may be something like /dashboard/property?property-id=35 or /dashboard/offer?offer-id=104&action=add
I tried using the Change Page Action, but I don’t think it will work because I cannot provide an array of query string variables. Only one variable with a set key.
I tried using the following JS, but it does not work… it produces a 404 error (this may have something to do with my DNS settings not being correct for naked URLS?)
@aurelie Outside of some form validation JS, Here are the three things that I’m often using which are more custom:
Changing page with multiple query items like mentioned above. This could be simply solved by allowing a bindable array with key/value query string parameters in the Change Page action.
Changing page to an outside URL in a workflow action. There is the ability to go to an outside URL with a link, but not an action … I’ve been using this with Stripe Checkout:
Login a user with an authToken … When using MagicLinks, the front end receives back an authToken. We then need to log that user in on the front end. There is no way to do this right now with the auth plugins … I’ve been doing this with 2 actions:
a) Setting the WeWeb accessToken (plugins.Xano.accessToken)
@kevinwasie I am currently trying to call an outside URL in a workflow, similar to the Stripe Checkout you mentioned. Used your example of the location.href, but it looks like the new URL is not opening on a blank page but is loaded into a frame or something. This is blocked by the external Service I am calling. Do you know a possibility to open an external URL in a workflow on a blank page?
Still on the free plan so I cannot test it unfortunately
Currently I try to figure out if it makes sense to move my application from bubble to WeWeb, so I rebuild and test the most important parts of my app in WeWeb before entering the paid plan.
Got it. Okay… What you have there should work when you publish, and if something is wrong in the code, there will be a simple fix for it. Just cant load external pages in the editor.
Testing actions that need redirect is not with the best dx in weweb.
If you need a redirect outside your weweb app try window.top.location.href = "your url here".
It will load the url in the topmost window so in the editor you will leave it and load the page.
If you need a return url (eg. stripe checkout) you need to dynamically build the url: if context.browser['environment'] == "editor" use https://editor.weweb.io/your app id/your page id otherwise create it with your published domain.
Because the editor load your app inside an iframe, be carefull with “window” inside editor :).
Normally you have a change page action which can help me and handle all these corner cases.
Change page action works only for pages of the weweb app right?
If I need to redirect to an external site and test the flow of actions (eg. stripe checkout, I want to test a full purchase flow including redirect to checkout and back to the editor) I need to change the location of the top window with something like window.top.location.href = "your url here".
A variable in context.browser with both the base editor url and the live app url will be helpful to set the redirects back to the app. Right now I am setting them by hand.
Hmm yes indeed Change Page is for now only for internal webpage.
I am sending to the product team your suggestions: Change Page action should be able to redirect to external + expose the base url on variable.
Yes! @aurelie And possibly the ability to bind array keys and values to the querystring variables. I think this will be a common request internally and externally.
This is exactly what I am currently looking for in this post I recently posted. I checked the product roadmap and don’t see anything about this feature. Do you know if this is being worked on?