Skip to content

Magento Custom Module Frontend Request Not Hitting Controller Endpoint (302 Found) #39477

@ghost

Description

Summary

I'm experiencing a persistent issue with my custom Magento 2 module. I have a frontend form integrated into a chat interface on my site. However, when I submit this form via a POST request, it's unexpectedly redirected to the homepage of my Magento site with a 302 Found response. This redirection prevents my custom controller logic from executing properly.

My goal is to create a message service using the OpenAI API, allowing me to send messages from the chat popup to my PHP code. This would enable me to retrieve products from the Magento website, send that data to ChatGPT, and return the response to the chat message container. Unfortunately, I'm unable to send the message and receive a response from the controller.

you can check it by your self the responce in console: https://magento.lahza.ma/

The module is enabled, and the chatbot container is appearing, which confirms that the HTML, CSS, and JavaScript are functioning correctly. The only issue seems to be with the PHP code and the AJAX request implementation. I've consulted various AI resources and checked numerous tutorials, but the same issue persists. The Magento 2 website is relatively new and doesn't have any significant background in Magento development. Over the past few days, I've learned how to create a custom module, but I'm struggling to resolve this bug. Any guidance on how to fix this issue would be greatly appreciated. this is the responce.
chat phtml
registrations php
default xml
module xml
send php
routes xml
l

Metadata

Metadata

Assignees

No one assigned

    Labels

    Issue: ready for confirmationReported on 2.4.xIndicates original Magento version for the Issue report.Triage: Dev.ExperienceIssue related to Developer Experience and needs help with Triage to Confirm or Reject it

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions