# URL Redirects & Velo Javascript

**URL:** <https://forum.wixstudio.com/t/url-redirects-velo-javascript/67957>\
**Category:** Ask the community\
**Tags:** code, question, wix\
**Created:** [January 25, 2025, 4:48pm UTC](https://forum.wixstudio.com/t/url-redirects-velo-javascript/67957 "2025-01-25T16:48:38Z")\
**Posts on this page:** 20\
**Page:** 1

<div class="post-metadata">

**Author:** ![user56028](https://avatars.discourse-cdn.com/v4/letter/u/779978/32.png) [@user56028](https://forum.wixstudio.com/u/user56028)\
**Post date:** [January 25, 2025, 4:48pm UTC](https://forum.wixstudio.com/t/url-redirects-velo-javascript/67957/1 "2025-01-25T16:48:38Z")

</div>

Problem: URL redirects don’t work unless the page is accessed directly (or browser is refreshed), as I believe Javascript is doing some sort of request or “Promise” with Velo.

- Example: websitedomaindotcom/products
- Click on a product (websitedomaindotcom/product-page/candle/) - a redirect already exists (websitedomaindotcom/product-page/candle/ TO newwebsitedomaindotcom/product/candle/)
- BUT website loads old URL
- Refresh the page, THEN it redirects to new page

How do I disable this Velo thing, or at least the portion that “ajax” loads the page so it’s a standard HTTPS request?

**Product:**  
The site is on the standard Wix Editor.

---

<div class="post-metadata">

**Author:** ![CODE-NINJA](https://sea1.discourse-cdn.com/wix/user_avatar/forum.wixstudio.com/code-ninja/32/110588_2.png) [@CODE-NINJA](https://forum.wixstudio.com/u/CODE-NINJA)\
**Post date:** [January 25, 2025, 5:49pm UTC](https://forum.wixstudio.com/t/url-redirects-velo-javascript/67957/2 "2025-01-25T17:49:58Z")

</div>

Getting such issues, are in most cases cause by the following …

a) You do not wait for your PAGE **to be ready first**  
b) You do not wait your DATASET **to be ready first** (if dataset is in usage)  
c) You do not use → **ASYNC-AWAIT** (wrong handling of **promises** )  
d) making a **request** and getting a **response** → **FETCH** ING DATA ← should also run **ASYNCHROUNOUS**.

**Example: ( a )**

```javascript
$w.onReady(()=>{console.log('Page is ready!!!');

});

```

**Example: ( b )**

```javascript
$w.onReady(()=>{console.log('Page is ready!!!');
    $w('#myDatasetIDHere').onReady(()=>{console.log('Dataset is ready!');
 
    });
});

```

**Example: ( c )**

```javascript
$w.onReady(()=>{console.log('Page is ready!!!');
    $w('#myDatasetIDHere').onReady(async()=>{console.log('Dataset is ready!');
         const results = await start_myAsynchronousFunction();
    });
});

async function start_myAsynchronousFunction() {
    console.log('..my function started...');     
}

```

**The same princip for http-requests!**

And there is another usecase if you refresh a dataset → dataset.refresh() \<—

---

<div class="post-metadata">

**Author:** ![user56028](https://avatars.discourse-cdn.com/v4/letter/u/779978/32.png) [@user56028](https://forum.wixstudio.com/u/user56028)\
**Post date:** [January 25, 2025, 5:57pm UTC](https://forum.wixstudio.com/t/url-redirects-velo-javascript/67957/3 "2025-01-25T17:57:14Z")

</div>

Your response was detailed, but unhelpful. How do I make the URL redirects work and disable the page pre-loading (or whatever it’s doing)?

---

<div class="post-metadata">

**Author:** ![CODE-NINJA](https://sea1.discourse-cdn.com/wix/user_avatar/forum.wixstudio.com/code-ninja/32/110588_2.png) [@CODE-NINJA](https://forum.wixstudio.com/u/CODE-NINJA)\
**Post date:** [January 25, 2025, 6:21pm UTC](https://forum.wixstudio.com/t/url-redirects-velo-javascript/67957/4 "2025-01-25T18:21:47Z")

</div>

Yes, as most as possible detailed, without even knowing your → CODE \<–, since you even did not provide your current running code !!!

You are asking inside the → **CODE-SECTION** \<–, right?

**WHERE IS YOUR CURRENT ISSUED CODE?**

You also did not describe what exactly you are doing and how looks like your **SETUP**!  
You also did not mention that you are working with **Wix-Stores**.

You are asking out of → NOWHERE ← but you are expecting an absolute detailed SOLUTION!

Maybe we first should learn how to describe your issued situation in detail and maybe add some images → and then ask for help!

And maybe you are just a AI-generated questioner → since you even do not have a NAME!  
 ![2025-01-25 19_30_49-Window](https://us1.discourse-cdn.com/wix/original/3X/2/c/2c3b89f3f1b0b3b294e080022422c71c7f1e55dc.png)

-------\> So many → MAY-BEES \<— and no real facts!

---

<div class="post-metadata">

**Author:** ![user56028](https://avatars.discourse-cdn.com/v4/letter/u/779978/32.png) [@user56028](https://forum.wixstudio.com/u/user56028)\
**Post date:** [January 25, 2025, 6:41pm UTC](https://forum.wixstudio.com/t/url-redirects-velo-javascript/67957/5 "2025-01-25T18:41:26Z")

</div>

It’s a Wix site. Just a basic website with products. I don’t think it’s that complicated.

Your hostility is off the charts!

---

<div class="post-metadata">

**Author:** ![CODE-NINJA](https://sea1.discourse-cdn.com/wix/user_avatar/forum.wixstudio.com/code-ninja/32/110588_2.png) [@CODE-NINJA](https://forum.wixstudio.com/u/CODE-NINJA)\
**Post date:** [January 25, 2025, 6:46pm UTC](https://forum.wixstudio.com/t/url-redirects-velo-javascript/67957/6 "2025-01-25T18:46:10Z")

</div>

> [@user56028](#):
>
> Your hostility is off the charts!

It is not my hostility, it is more how much efforsts you make → to get a valuable answer.  
Just to ask a question, generated in 5 sec. without any details → and then expecting a one-shot solution (for free) 🤔

But i know such persons like you! And i teach them how to do it better!

Sorry again → MY HOSTILITY!

---

<div class="post-metadata">

**Author:** ![user56028](https://avatars.discourse-cdn.com/v4/letter/u/779978/32.png) [@user56028](https://forum.wixstudio.com/u/user56028)\
**Post date:** [January 25, 2025, 6:47pm UTC](https://forum.wixstudio.com/t/url-redirects-velo-javascript/67957/7 "2025-01-25T18:47:47Z")

</div>

I suppose I’m not asking the right questions then. I know very little about the Wix editor (I’m used to Wordpress/woocommerce). I also know literally nothing about Velo, and very little about JS. What do you need?

---

<div class="post-metadata">

**Author:** ![CODE-NINJA](https://sea1.discourse-cdn.com/wix/user_avatar/forum.wixstudio.com/code-ninja/32/110588_2.png) [@CODE-NINJA](https://forum.wixstudio.com/u/CODE-NINJA)\
**Post date:** [January 25, 2025, 7:15pm UTC](https://forum.wixstudio.com/t/url-redirects-velo-javascript/67957/8 "2025-01-25T19:15:33Z")

</div>

Now we are on the right track!

Ok! Question…

1. Do you use CODE in your setup?

a) If not → show your setup (pics) → describe your process-flow.  
b) If you have already integrated some code on your site, related to your issue → show show it.

Your description could/should be like…

1. When i am on my Product-Page, i do the following action + (pic)
2. But when i do the action → something goes wrong.
3. I did setup a redirect → pic of showing how you exactly did it
4. Since i am not using CODE → i will present my SETUP in PICS and describe which elements are involved…

**used-elements…**  
-button (id)  
-dataset(dataset-id)

**process-flow…**

1. my process starts with  
2)…  
3)…  
4)…
2. and ends with the issue that i get a wrong redirection and it only works after refresh.

ADDITIONAL:  
I have implemented some → CONSOLE-LOGS ← which maybe could help to solve the issue.

**Ok, and now slowly!**

1. I understand that you are not familiar with wix.
2. But you should udnerstand, that only you see your generated SETUP in front of you.  
If you would have done everything by code → you just would have to show your code → so it would be easy to detect the issue very fast by code-investigation.  
But since you do not use code and anybody can really see how you have contructed your setup, it is difficult to imagine what is going on, on your side.
3. This is why a more detailed description (including pics) would surely help much more to solve your problem.

You can also try to solve it on your own → by implementing some console-logs into your setup.

How to do?

1. You activate the DEV-MODE (developer-mode) in your wix-editor ( already done? );
2. You navigate to your product page (i asume that the product page is our starting point).
3. Since you started the dev-mode, you now see more options in your wix-editor → now you are not only a DESIGNER, but also a → PROGRAMMER.

Let’s do some investigations…

1. Add the following CODE into your Product-page…

```javascript
$w.onReady(async function() {
    $w('#productPage1').onReady(()=>{
        get_myProduct();
    });
});

function get_myProduct() {
    $w('#productPage1').getProduct()
    .then(async(product) => {
        console.log("Product: ", product);
    });
}

```

This should show you the current data of your product inside the console.  
Try this first and show what you get…

If this information is not enough… take a look here…

> [@Image is not fetching from the collection](https://forum.wixstudio.com/t/image-is-not-fetching-from-the-collection/4448/11):
>
> @soniaayush24400 Now i understand why i did not understand your SETUP! Yes it was not a dynamic page directly, but it is some kind of a dynamic page, fired through the Wix-Stores-App. And yes, it was also not a REPEATER. However, you can not enter produtcs-database by a usage of a query (correct me if i am wrong at this point Velo-Masters), but though i got it to work, at least i could get all these inofrmations for you out of the Products-Database… -------------------------------- CORRECTI…

…there you will find the full code of how to get PRODUCT-DATA logged into your CONSOLE.

How to use → CONSOLE \<— ???

If you are using → GOOGLE-CHROME → PRESS-F12 ← and navigate to console.

Investigate the results.

---

<div class="post-metadata">

**Author:** ![user56028](https://avatars.discourse-cdn.com/v4/letter/u/779978/32.png) [@user56028](https://forum.wixstudio.com/u/user56028)\
**Post date:** [January 25, 2025, 7:23pm UTC](https://forum.wixstudio.com/t/url-redirects-velo-javascript/67957/9 "2025-01-25T19:23:42Z")

</div>

I will dig into this and see what I can find. Thank you!

---

<div class="post-metadata">

**Author:** ![CODE-NINJA](https://sea1.discourse-cdn.com/wix/user_avatar/forum.wixstudio.com/code-ninja/32/110588_2.png) [@CODE-NINJA](https://forum.wixstudio.com/u/CODE-NINJA)\
**Post date:** [January 25, 2025, 7:25pm UTC](https://forum.wixstudio.com/t/url-redirects-velo-javascript/67957/10 "2025-01-25T19:25:17Z")

</div>

> [@user56028](#):
>
> What do you need?

Take your time and read carefully, or provide pisc of setup and describe each step from start to end.

---

<div class="post-metadata">

**Author:** ![codequeen](https://sea1.discourse-cdn.com/wix/user_avatar/forum.wixstudio.com/codequeen/32/88960_2.png) [@codequeen](https://forum.wixstudio.com/u/codequeen)\
**Post date:** [January 25, 2025, 7:43pm UTC](https://forum.wixstudio.com/t/url-redirects-velo-javascript/67957/11 "2025-01-25T19:43:03Z")

</div>

I feel like this is more of a “I had an old domain, connected a new domain but my old domain is still being displayed in the browser bar” sort of question instead of a Velo issue where you actually wrote Velo code gone wrong.

Based on what you show here…

> [@user56028](#):
>
> newwebsitedomaindotcom/product/candle/)

If so, you need to swap the domain as main vs secondary.

> **[Connecting Multiple Domains to One Wix Site | Help Center | Wix.com](https://support.wix.com/en/article/connecting-multiple-domains-to-one-wix-site)**
>
> Connect an unlimited number of domains to a single Wix site. Your primary domain connects directly to your site and is your site's main address (URL). Any addit

> **[Switching Your Primary and Redirected Domains | Help Center | Wix.com](https://support.wix.com/en/article/switching-your-primary-and-redirected-domains)**
>
> Your primary domain is the main address (URL) for your site. Any additional domains you connect to your site redirect to your primary domain. You can set a redi

If not, post a screenshot of your code and/or a video to better visualize what you are trying to articulate.

---

<div class="post-metadata">

**Author:** ![user56028](https://avatars.discourse-cdn.com/v4/letter/u/779978/32.png) [@user56028](https://forum.wixstudio.com/u/user56028)\
**Post date:** [January 25, 2025, 8:37pm UTC](https://forum.wixstudio.com/t/url-redirects-velo-javascript/67957/12 "2025-01-25T20:37:48Z")

</div>

Thanks for the suggestion @codequeen , but it’s not quite that.

OLD domain: hosted with Wix  
NEW domain: hosted on another server

---

<div class="post-metadata">

**Author:** ![user56028](https://avatars.discourse-cdn.com/v4/letter/u/779978/32.png) [@user56028](https://forum.wixstudio.com/u/user56028)\
**Post date:** [January 25, 2025, 8:38pm UTC](https://forum.wixstudio.com/t/url-redirects-velo-javascript/67957/13 "2025-01-25T20:38:47Z")

</div>

I put this screen capture together. Does that make more sense?

EDIT: uploaded somewhere else for easy viewing

> **[redirect issue.mov](https://jumpshare.com/s/vgIyjQazzYMSzVTiUpR1)**
>
> Shared with Jumpshare

---

<div class="post-metadata">

**Author:** ![user56028](https://avatars.discourse-cdn.com/v4/letter/u/779978/32.png) [@user56028](https://forum.wixstudio.com/u/user56028)\
**Post date:** [January 25, 2025, 8:54pm UTC](https://forum.wixstudio.com/t/url-redirects-velo-javascript/67957/14 "2025-01-25T20:54:48Z")

</div>

I also put the code you mentioned in my product page:

 ![image](https://us1.discourse-cdn.com/wix/original/3X/b/2/b2d55ecbf9040b082549215f502c88d5094dfbf8.png)

---

<div class="post-metadata">

**Author:** ![user56028](https://avatars.discourse-cdn.com/v4/letter/u/779978/32.png) [@user56028](https://forum.wixstudio.com/u/user56028)\
**Post date:** [January 25, 2025, 8:55pm UTC](https://forum.wixstudio.com/t/url-redirects-velo-javascript/67957/15 "2025-01-25T20:55:25Z")

</div>

But this is what it says:

 ![image](https://us1.discourse-cdn.com/wix/original/3X/6/3/63baeb4d5cc1777b9a31b8aad8cb1bde58a50162.png)

What am I missing?

---

<div class="post-metadata">

**Author:** ![CODE-NINJA](https://sea1.discourse-cdn.com/wix/user_avatar/forum.wixstudio.com/code-ninja/32/110588_2.png) [@CODE-NINJA](https://forum.wixstudio.com/u/CODE-NINJA)\
**Post date:** [January 25, 2025, 9:03pm UTC](https://forum.wixstudio.com/t/url-redirects-velo-javascript/67957/16 "2025-01-25T21:03:57Z")

</div>

My fault! → There was 1 → **onReady** too much!  
 ![2025-01-25 22_05_11-Window](https://us1.discourse-cdn.com/wix/original/3X/8/a/8a0b50b242abc15787c2535d1e4fa1e2948c0cb1.png)

Try this…

```javascript
$w.onReady(async function() {
    get_myProduct();
});

function get_myProduct() {
    $w('#productPage1').getProduct()
    .then(async(product) => {
        console.log("Product: ", product);
    });
}

```

Take a look onto the REPLY of → **CODE-QUEEN**!

---

<div class="post-metadata">

**Author:** ![user56028](https://avatars.discourse-cdn.com/v4/letter/u/779978/32.png) [@user56028](https://forum.wixstudio.com/u/user56028)\
**Post date:** [January 25, 2025, 9:08pm UTC](https://forum.wixstudio.com/t/url-redirects-velo-javascript/67957/17 "2025-01-25T21:08:11Z")

</div>

Thanks @CODE-NINJA ! Now I have a JSON table of data. Can I use some of that data along with Velo functions now to “turn off” the way the browser requests the URL?

---

<div class="post-metadata">

**Author:** ![CODE-NINJA](https://sea1.discourse-cdn.com/wix/user_avatar/forum.wixstudio.com/code-ninja/32/110588_2.png) [@CODE-NINJA](https://forum.wixstudio.com/u/CODE-NINJA)\
**Post date:** [January 25, 2025, 9:11pm UTC](https://forum.wixstudio.com/t/url-redirects-velo-javascript/67957/18 "2025-01-25T21:11:12Z")

</div>

Did you already read this … the additional post, i gave you?

Now → **UPGRADE YOUR CODE…**

```javascript
function start_Process() {
    $w('#productPage1').getProduct()
    .then(async(product) => {console.log("Product: ", product);
        let productName = product.name; console.log("Product-Name: ", productName);
        let productDescription = product.description; console.log("Product-Description: ", productDescription);
        let currency = product.currency; console.log("Currency: ", currency);
        let discountedPrice = product.discountedPrice; console.log("Discounted-Price: ", discountedPrice);
        let inStockAvailability = product.inStock; console.log("In Stock available: ", inStockAvailability);
        let inventoryItemId = product.inventoryItemId; console.log("Inventory-Item-ID: ", inventoryItemId);
        let productImage = product.mainMedia; console.log("Product-Image: ", productImage);
        let productMediaItems = product.mediaItems; console.log("Product-Media-Items: ", productMediaItems);
        let productPrice = product.price; console.log("Product-Price: ", productPrice);
        let productPageURL = product.productPageUrl; console.log("Product-Page-URL: ", productPageURL);
    }).catch((error)=>{console.error(error);});   
}

```

Check all data and see if you already have found something, you can use, if not → investigate more…

Once you understand the PRODUCT-PAGE → maybe you will get a better OVERVIEW and an IDEA what to do to be able to resolve your issue.

---

<div class="post-metadata">

**Author:** ![user56028](https://avatars.discourse-cdn.com/v4/letter/u/779978/32.png) [@user56028](https://forum.wixstudio.com/u/user56028)\
**Post date:** [January 25, 2025, 9:13pm UTC](https://forum.wixstudio.com/t/url-redirects-velo-javascript/67957/19 "2025-01-25T21:13:30Z")

</div>

@CODE-NINJA no, I did not see that I could expand the quoted post. Taking a look now.

EDIT: it won’t let me post more than 20 times so I’m replying here.

@CODE-NINJA I’m not sure that post is applicable, except for getting the JSON data the console provides. Did you watch the screen capture I made? That clearly describes my issue, but perhaps I’m missing something?

EDIT 2:

> [@CODE-NINJA](#):
>
> So what if you could start an automatic → PAGE-REFRESH → by CODE? ?

Yes! That would work! Hmm, how do I do that @CODE-NINJA ??

---

<div class="post-metadata">

**Author:** ![CODE-NINJA](https://sea1.discourse-cdn.com/wix/user_avatar/forum.wixstudio.com/code-ninja/32/110588_2.png) [@CODE-NINJA](https://forum.wixstudio.com/u/CODE-NINJA)\
**Post date:** [January 25, 2025, 9:16pm UTC](https://forum.wixstudio.com/t/url-redirects-velo-javascript/67957/20 "2025-01-25T21:16:22Z")

</div>

> [@CODE-NINJA](#):
>
> `let productPageURL = product.productPageUrl; console.log("Product-Page-URL: ", productPageURL);`

What about →   
`let productPageURL = product.productPageUrl; console.log("Product-Page-URL: ", productPageURL);`

What is the RESULT ?

There is surely more included data, you can get out of the LOG.  
Check the main-log → **console.log("Product: ", product);**

UPGRADE your CODE → so you expand all logs and see everything what a PRODUCT-PAGE offers you.

[Next page](https://forum.wixstudio.com/t/url-redirects-velo-javascript/67957.md?page=2)
