symfony / ux

Symfony UX initiative: a JavaScript ecosystem for Symfony
https://ux.symfony.com/
MIT License
847 stars 312 forks source link

[ux-turbo] redirect truncated url #211

Open LabInc-Nico opened 2 years ago

LabInc-Nico commented 2 years ago

Hi,

After the installation of ux-turbo (SF6.0), the urls are truncated with the symbol # following a redirect (without use of ux-turbo)

symfony new test --full
composer req encore
pnpm install -D symfony/stimulus-bridge @hotwired/stimulus
composer require symfony/ux-turbo
pnpm install --force
symfony make:controller Home
pnpm watch
# templates/Home/index.html.twig
{% block body %}
    <form action="{{ path('checkout') }}" method="POST" class="d-flex justify-content-center">
        <button type="submit">GO</button>
    </form>
{% endblock %}
# Controller/HomeController.php
    #[Route('/checkout', name: 'checkout', methods: ["POST"])]
    public function checkout(): Response
    {
       $url = "https://url.com/foo/aaaaaaaaaaa#bbbbb";
       $this->redirect($url,303);  //url in a new tab is https://url.com/foo/aaaaaaaaaaa
    }
LabInc-Nico commented 2 years ago

ok, Turbo Drive converts form submissions to AJAX calls.. Adding data-turbo=false bypasses the problem :


# templates/Home/index.html.twig
{% block body %}
  <div data-turbo="false">
    <form action="{{ path('checkout') }}" method="POST" class="d-flex justify-content-center">
        <button type="submit">GO</button>
    </form>
  </div>
{% endblock %}
carsonbot commented 6 months ago

Thank you for this issue. There has not been a lot of activity here for a while. Has this been resolved?

carsonbot commented 5 months ago

Friendly ping? Should this still be open? I will close if I don't hear anything.

carsonbot commented 5 months ago

Hey,

I didn't hear anything so I'm going to close it. Feel free to comment if this is still relevant, I can always reopen!