Server-side loading doesn’t seem to work

The docs say:

If a change page action is the only action in a workflow that is triggered on page load, the redirection will happen on the server.

I seem to be doing this exact thing on my 404 page:

And yet the page is visibly loaded before sending to the index.

Am I doing something wrong?

Hey @vovazk

You’re not doing anything wrong. The workflow waits for the page to load therefore you see it visibly load.

Two options:

  • if you always want to redirect from this page (as in there are no conditions on this workflow), you can set up a redirect in your app settings.

  • if it is conditional (eg you first want to check if user is logged in): you can put everything on that page in one container group, set the visibility to hidden in page load, and include a condition on that group that says the opposite of your redirect condition e.g. if user is logged in, make group visible. That way although that page still loads, it does not display anything.

Oh. I assumed server-side loading would do a simple redirect without any rendering. Is there a way to do this?

App settings (as you suggested) wouldn’t work for me, as I need to redirect based on user’s profile slug (e.g. I need mydomain.com/vova redirect to mydomain.com/index/vova), and as you can understand there can be an arbitrary number of slugs.

(I have a single-page app, hence index/ and not users/)

Do you know if there’s a simple way to enable this?

You can’t have mydomain.com/vova, as slugs are aways linked to a page, example : mydomain.com/index/vova (i’ this case, the index page is of type Users).

You can maybe use url parameter? So that mydomain.com/?user=vova can be redirected to mydomain.com//vova

What you can also achieve is to have the index page without any element and type = Users. When page loaded, you’ll set a Workflow doing a redirect to the single page of your app. In this case, the index page is used as a simple “router”.

Mydomain.com/index/vova redirected to mydomain.com//vova if vova exists as a slug in your users db

Another option could be using the Saasalias plugin. Not cheap but using it you can also create a subdomain vova.mydomain.com redirected to mydomain.com (with index page type = Users, and you set a workflow to set the user as the data source of the page, based on the subdomain). And this redirect can be transparent, that means that even if the redirect in mydomain.com/index/vova, your user will always see only “vova.mydomain.com”.

Depending on your needs and app goals, it can worth the price.

redirected how?

Anyway, here’s how I solved this. This workaround is kind of ugly and beautiful at the same time lol:

First, I cleared the 404 in its entirety (to make it load faster), and added the following action on page load:

Thus, navigating to mydomain.com/vova/projects (for example) redirects to Web Hosting, Domain Name Registration - MyDomain.com

On the index page’s load, the (free) Router plugin replaces the path in the browser with the one it received from the 404 page:

Now you can navigate within your single-page app by parsing Router’s path list as exemplified in @ZeroqodeTeam’s demo project

One thing to note is that the router Plugin for some example doesn’t catch up 1st Path/2nd Path in this case, but does catch the “Path list” parameter. Note that “1st Path” in this case is its item #3. Confusing, I know.

Anyway, this seems to work.

1 Like

Missing “index” between the 2 slashes :wink:

Your workaround is not ugly as long as perf are good and you get the expected result :ok_hand:t2:

Thanks. I’m just not sure how search engines will treat this. See, I plan to have a lot of pages exposed (this can be /vova/some-project-name), which I want to be indexed. I’m not sure Google will understand that redirect and fetch the content correctly from the page. I will have to deploy before seeing if it works, though…

Using Saasalias, you could have vova.mydomain.com/project/projectname, what could be better for SEO and referencing purpose.

Just for info, I don’t get any royalty on saasalias plugin sales :grinning_face_with_smiling_eyes:

I want to stick to free options as far as possible. If the app catches up I can consider this or other paid plugins.

But to be clear I don’t want it to route to projects/…, I want the structure to be [domain]/[username]/[project]

Yes, understood. You won’t be able to build a url using 2 successive dynamic page, but the free router plugin may help to get a solution close to your expectations. Not sure about Metadata and SEO, let us know!