elleracompany / craft-cookie-consent

GDPR-Compliant cookie consent banner for Craft CMS
Other
6 stars 5 forks source link

404 Not Found when accessing /cookie-consent/show #92

Closed okkimus closed 1 year ago

okkimus commented 1 year ago

Hi!

We are trying to implement cookie consent feature for client using your plugin. I'm having trouble with fetching the consent given from the /cookie-consent/show route.

Steps to reproduce:

  1. Add cookie consent.
  2. Go to the page:
    • consent box is shown
    • accept wanted cookies
  3. Site sends request to {MY_DOMAIN}/cookie-consent/show.
  4. Request returns 404 status.
  5. window.ccc remains empty.

Setup

Running on Craft CMS PRO 3.7.46 and plugin version is 1.6.1. We have tried the implementation with custom and default template. We noticed some earlier issues with omitting some of the links/buttons (https://github.com/elleracompany/craft-cookie-consent/issues/56), but adding those didn't help either.

Potential error

To me it seems like the request to backend controller is failing. This was somewhat related to https://github.com/elleracompany/craft-cookie-consent/issues/89, but when I updated the URL by hand to have only one slash, the URL was still returning 404. As I inspected the response via network tab, I noticed that Craft is trying to return template instead of calling the plugin's API endpoint. This results in 404 as said template doesn't exist.

Exact error and error location

Error on browser console:

GET https://{ MY_DOMAIN }/cookie-consent/show 404
addWindowObject @ script.js
xhr.onreadystatechange @ script.js
XMLHttpRequest.send (async)
submitConsent @ script.js

Excerpt from network tab's response:

[HTTP 404 – Not Found](http://en.wikipedia.org/wiki/List_of_HTTP_status_codes#404) – [yii\web\NotFoundHttpException](http://www.yiiframework.com/doc-2.0/yii-web-notfoundhttpexception.html)
Template not found: cookie-consent/show

...
<More stacktrace>

And the error is thrown inside the call of https://github.com/elleracompany/craft-cookie-consent/blob/master/src/resources/script.js#L82 at https://github.com/elleracompany/craft-cookie-consent/blob/master/src/resources/script.js#L157.

Any tips that could help?

jellingsen commented 1 year ago

Hi okkimus.

I've replicated your stack with the correct plugin version and the correct craft version, but I'm unable to reproduce.

I'll contact you privatly for more details and update this issue when we solve it.

Screenshot 2022-09-29 at 13 47 47
okkimus commented 1 year ago

Thanks for the reply! 🙏

I think it might be clashing with some other plugins we have. We decided to move on with other solution for now. I might come back to this later (probably not).