Closed 96imranahmed closed 2 months ago
+1
Running the code below in react gives Cors error:
import SpeedTest from '@cloudflare/speedtest'
;
new SpeedTest().onFinish = results => console.log(results.getSummary());
Access to fetch at '[https://speed.cloudflare.com/turn-creds](vscode-file://vscode-app/Applications/Visual%20Studio%20Code.app/Contents/Resources/app/out/vs/code/electron-sandbox/workbench/workbench.html)' from origin '[http://localhost:3000](vscode-file://vscode-app/Applications/Visual%20Studio%20Code.app/Contents/Resources/app/out/vs/code/electron-sandbox/workbench/workbench.html)' has been blocked by CORS policy: The 'Access-Control-Allow-Origin' header contains the invalid value 'speed.cloudflare.com'.
+1 having issues with the turn-creds CORS
@96imranahmed how did you do the workaround for packetLoss??
Sorry I wasn't clear - I don't have a solution for getting a packetLoss metric. I just ignore the test entirely by removing it from the list of default measurements that are run when you make a test.
{ type: 'latency', numPackets: 1 }, // initial ttfb estimation
{ type: 'download', bytes: 1e5, count: 1, bypassMinDuration: true }, // initial download estimation
{ type: 'latency', numPackets: 20 },
{ type: 'download', bytes: 1e5, count: 9 },
{ type: 'download', bytes: 1e6, count: 8 },
{ type: 'upload', bytes: 1e5, count: 8 },
{ // Remove this line
type: 'packetLoss',
numPackets: 1e3,
batchSize: 10,
batchWaitTime: 10, // ms (in between batches)
responsesWaitTime: 3000 // ms (silent time after last sent msg)
},
{ type: 'upload', bytes: 1e6, count: 6 },
{ type: 'download', bytes: 1e7, count: 6 },
{ type: 'upload', bytes: 1e7, count: 4 },
{ type: 'download', bytes: 2.5e7, count: 4 },
{ type: 'upload', bytes: 2.5e7, count: 4 },
{ type: 'download', bytes: 1e8, count: 3 },
{ type: 'upload', bytes: 5e7, count: 3 },
{ type: 'download', bytes: 2.5e8, count: 2 }
We will apply a fix in the next days.
@joao-reis Please let me know when fix is released :D
Fixed 👍
Works perfectly - thanks for the quick turnaround! Let me close this!
Hi there, the default config is failing because the
packetLoss
test querieshttps://speed.cloudflare.com/turn-creds
However, the CORS policy for this page is set to only accept cloudflare domains (e.g.,
access-control-allow-origin: speed.cloudflare.com
)A workaround is to remove packetLoss calculations from the test, but I'd love to be able to also use packetLoss stats in the reporting on my app!