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.
Hello @stufflhdgm8125
The 429 Too Many Requests error is an HTTP status code that indicates a user has sent too many requests in a given amount of time.
Poorly designed module logic: If your module has loops or unnecessary API calls within a single request, it can quickly exceed the rate limit.
Reduce unnecessary API calls: Review your module's logic and identify areas where you can batch requests or minimize unnecessary API calls.
In your controller actions, catch the Magento\Framework\Exception\LocalizedException that is thrown when the rate limit is exceeded.
Hope it helps !
If you find our reply helpful, please give us kudos.
A Leading Magento Development Agency That Delivers Powerful Results, Innovation, and Secure Digital Transformation.
WebDesk Solution Support Team
Get a Free Quote | | Adobe Commerce Partner | Hire Us | Call Us 877.536.3789
Thank You,
WebDesk Solution Support Team
Get a Free Quote | Email | Adobe Commerce Partner | Hire Us | Call Us 877.536.3789
Location: 150 King St. W. Toronto, ON M5H 1J9