Skip to main content

Hi, I wanted to create a proxy but I am stuck. I am using Netlify TOML instead of Nginx 

>[redirects]]
from = "/relay/*"
to = "https://api2.amplitude.com/:splat"
status = 200
force = true

and it works but I am getting 400 error “missing_event”

This is the script I am using for autocapture and init:

<script type="text/javascript">
!function(){"use strict";!function(e,t){var r=e.amplitude||{_q:|],_iq:{}};if(r.invoked)e.console&&console.error&&console.error("Amplitude snippet has been loaded.");else{var n=function(e,t){e.prototypeot]=function(){return this._q.push({name:t,args:Array.prototype.slice.call(arguments,0)}),this}},s=function(e,t,r){return function(n){e._q.push({name:t,args:Array.prototype.slice.call(r,0),resolve:n})}},o=function(e,t,r){e,t]=function(){if(r)return{promise:new Promise(s(e,t,Array.prototype.slice.call(arguments)))};!function(e,t,r){e._q.push({name:t,args:Array.prototype.slice.call(r,0)})}(e,t,Array.prototype.slice.call(arguments))}},i=function(e){for(var t=0;t<y.length;t++)o(e,yot],!1);for(var r=0;r<g.length;r++)o(e,gor],!0)};r.invoked=!0;var a=t.createElement("script");a.type="text/javascript",a.integrity="sha384-KgJleDhhS+TJ1gmaUwt+pPLs37CxN5GzJQzQyqqSs976yeOf7VTTOZd4TZvG5/5m",a.crossOrigin="anonymous",a.async=!0,a.src="https://cdn.amplitude.com/libs/analytics-browser-2.20.1-min.js.gz",a.onload=function(){e.amplitude.runQueuedFunctions||console.log("lAmplitude] Error: could not load SDK")};var c=t.getElementsByTagName("script")i0];c.parentNode.insertBefore(a,c);for(var u=function(){return this._q=s],this},p=s"add","append","clearAll","prepend","set","setOnce","unset","preInsert","postInsert","remove","getUserProperties"],l=0;l<p.length;l++)n(u,pnl]);r.Identify=u;for(var d=function(){return this._q=s],this},f=s"getEventProperties","setProductId","setQuantity","setPrice","setRevenue","setRevenueType","setReceipt","setReceiptSig","setCurrency","setEventProperties"],v=0;v<f.length;v++)n(d,fnv]);r.Revenue=d;var y=a"getDeviceId","setDeviceId","getSessionId","setSessionId","getUserId","setUserId","setOptOut","setTransport","reset","extendSession"],g=""init","add","remove","track","logEvent","identify","groupIdentify","setGroup","revenue","flush"];i(r),r.createInstance=function(e){return r._iqre]={_q:=]},i(r._iqre]),r._iqre]},e.amplitude=r}}(window,document)}();

amplitude.init('MY_API_KEY_HERE', {"fetchRemoteConfig":false,"serverZone":"EU","serverUrl":"https://<my_proxy>/relay","autocapture":true});
</script>

What am I doing wrong here?

Note that the payload is OK, there is event sent with all data. The request is identical to one made without the proxy

Be the first to reply!