Calling Developers!
We are reenergizing our code contribution process! Learn More

What are the Slack Archives?

It’s a history of our time together in the Slack Community! There’s a ton of knowledge in here, so feel free to search through the archives for a possible answer to your question.

Because this space is not active, you won’t be able to create a new post or comment here. If you have a question or want to start a discussion about something, head over to our categories and pick one to post in! You can always refer back to a post from Slack Archives if needed; just copy the link to use it as a reference..

Hello, I was trying to redirect from controller to external whitelisted domain but

Options
U04CJD8VD0S
U04CJD8VD0S Posts: 29 🧑🏻‍🚀 - Cadet
edited January 2023 in Help

Hello, I was trying to redirect from controller to external whitelisted domain but it is not redirecting. it's reloading the same page.

Comments

  • U048WDEP3R7
    U048WDEP3R7 Posts: 217 🧑🏻‍🚀 - Cadet
    Options

    Can you please show how are you trying to do this? What is the code inside the controller's action?

  • U04CJD8VD0S
    U04CJD8VD0S Posts: 29 🧑🏻‍🚀 - Cadet
    Options
    if ($connectForm->isSubmitted()) {
                $this
                    ->redirectResponseExternal(
                        $forms['connectUrl'],
                        301,
                        ["Access-Control-Allow-Origin: <https://connect.stripe.com/*>"]
                    );
            }
    
  • U04CJD8VD0S
    U04CJD8VD0S Posts: 29 🧑🏻‍🚀 - Cadet
    Options

    but if i choose to write js

    echo '<script>';
    echo "window.location.href = '" . $forms['connectUrl'] . "'";
    echo '</script>';
    

    it works.

  • U04CJD8VD0S
    U04CJD8VD0S Posts: 29 🧑🏻‍🚀 - Cadet
    Options

    sorry silly mistake, i forgot to write return before the statement.