Javascript tracker not hitting AWS load balancer , error is as below:
Access to XMLHttpRequest at ‘htttp:/xxxxxxx/’ from origin ‘http://ec2-xxxxxx:8000/’ has been blocked by CORS policy: Response to preflight request doesn’t pass access control check: Redirect is not allowed for a preflight request.
The origin server is an ec2 instance has Amazon Linux and Django service running inside Docker.
I am running Django application from within browser.
Within Django home page, I have added javascript tracker as of try pages:
sorry to hear you’re having problems tracking the events.
There are two main things to check:
First, you seem to be using an http URL which might be getting redirected to https leading to 3xx status being passed. And for preflight you need to get a 2xx. Please do make sure that there is no redirect happening on that request as the browser will drop it.
Second, if the request has no Origin header set, the collector sets Access-Control-Allow-Origin to * which will be discarded in newer browsers.
There seems to be no issue using collector url provided by Snowplow Try, but issue starts when I use AWS collector URL(dns name, autogenerated while installing snowplow using terraform).
Can you please tell me why so?
I am using 2 demo application, one is ReactJS app, another is Django app.
The snowplow try can track events from both the applications but the AWS collector can’t.
Have you checked the URL scheme (HTTP/HTTPS) and SSL certificates for the domain are resolving properly. The ones you supplied in the inputs for the modules. You are most likely hitting the first case I mentioned before. Something redirects the OPTIONS request and that must be the ALB.
You can try validating that using for instance curl.
Hi @achintya.c, welcome to the community! Just to set expectations, the support you receive here is not likely to be instant. This is an open source community with no guarantee of response times.
There is a lot of documentation available around Snowplow, but for cloud related issues you’ll need to bring a certain amount of understanding and consult their documentation to fill the gaps.
Do I need to add set origin in javascript tracker?
You shouldn’t need to unless your environment sets the value to something different than you’re expecting it to do so. The XHR calls issued from within your browser should have those values set properly. Again, unless your runtime environment does something weird.
How can I allow load balancer to accept cross region requests through browser?
This is not something that we’d encourage for users to do as it opens up a security loophole. I believe that there probably is a way to modify the ALB responses for the listener to respond with static 200 and fixed set of CORS-headers when it receives an OPTIONS request. But you’d need to consult AWS docs for that.
My suggestion is you debug the XHR calls being passed around between your application and the collector. The Origin headers are the interesting ones on those requests.
Please keep in mind that we do provide full support and assistance for private SaaS BDP customers for whom we run Snowplow pipelines but we can’t really assist with the kind of work for Open Source users.
Good news is that , my javascript tracker is working and it is reaching s3 bucket (enriched). Now my question is that, why it is not automatically loading in Postgre Database?
I believe the answer should be somewhere in the postgres loader’s logs. Is the service running? Are you getting any bad events? In more general sense, are there any errors? The logs should provide you the answer.