"platform_id+project_id+user_id+session_id+event_subtype"wrangler.tomlindex.jsindex.js but it's still giving errors (I replaced projectname and account). Giving errors for both localhost and for when I go on the deployed siteindex.js fileindex.jsTypeError: Load failed

[env.production]
analytics_engine_datasets = [{ binding = "ANALYTICS", dataset = "event_logs" }]<account><account>[Error] Origin http://localhost:5173 is not allowed by Access-Control-Allow-Origin. Status code: 500
[Error] Fetch API cannot load https://event-tracking-worker.<account>.workers.dev/ due to access control checks.
[Error] Failed to load resource: Origin http://localhost:5173 is not allowed by Access-Control-Allow-Origin. Status code: 500 (event-tracking-worker.<account>.workers.dev, line 0)[Error] Origin http://localhost:5173 is not allowed by Access-Control-Allow-Origin. Status code: 500
[Error] Fetch API cannot load https://event-tracking-worker.<account>.workers.dev/ due to access control checks.
[Error] Failed to load resource: Origin http://localhost:5173 is not allowed by Access-Control-Allow-Origin. Status code: 500 (event-tracking-worker.<account>.workers.dev, line 0)[Error] Origin https://projectname.pages.dev is not allowed by Access-Control-Allow-Origin. Status code: 500
[Error] Fetch API cannot load https://event-tracking-worker.<account>.workers.dev/ due to access control checks.
[Error] Failed to load resource: Origin https://projectname.pages.dev is not allowed by Access-Control-Allow-Origin. Status code: 500 (event-tracking-worker.<account>.workers.dev, line 0)tags[Error] Origin http://localhost:5173 is not allowed by Access-Control-Allow-Origin. Status code: 500
[Error] Fetch API cannot load https://event-tracking-worker.<account>.workers.dev/ due to access control checks.
[Error] Failed to load resource: Origin http://localhost:5173 is not allowed by Access-Control-Allow-Origin. Status code: 500 (event-tracking-worker.<account>.workers.dev, line 0)
[Error] Error logging event:
TypeError: Load failed
(anonymous function) (logEventUtility.js:20)logEventUtility.jsexport default {
async fetch(request, env) {
if (request.method === 'POST') {
// Parse the incoming request body
const requestBody = await request.json();
const eventType = requestBody.eventType || 'unknown_event';
const url = requestBody.url || 'unknown_url';
// Log the event using the Workers Analytics Engine
await env.ANALYTICS.writeDataPoint({
blobs: [eventType, url],
indexes: [eventType],
tags: [url],
});
return new Response("Event logged successfully!", { status: 200 });
} else {
return new Response("Method Not Allowed", { status: 405 });
}
}
};export const logEvent = async (eventType) => {
try {
// Replace with your actual worker URL
const workerUrl = "https://event-tracking-worker.<account>.workers.dev/";
// Send event data to the Cloudflare Worker
const response = await fetch(workerUrl, {
method: "POST", // Use POST or GET as per your preference
headers: {
"Content-Type": "application/json",
},
body: JSON.stringify({
eventType: eventType,
url: window.location.href, // Include the current page URL
}),
});
if (!response.ok) {
console.error("Failed to log event", response.statusText);
}
} catch (error) {
console.error("Error logging event:", error);
}
};export const logEvent = async (eventType) => {
try {
// Replace with your actual worker URL
const workerUrl = "https://event-tracking-worker.<account>.workers.dev/";
// Send event data to the Cloudflare Worker
const response = await fetch(workerUrl, {
method: "POST", // Use POST or GET as per your preference
headers: {
"Content-Type": "application/json",
},
body: JSON.stringify({
eventType: eventType,
url: window.location.href, // Include the current page URL
}),
});
if (!response.ok) {
console.error("Failed to log event", response.statusText);
}
} catch (error) {
console.error("Error logging event:", error);
}
};export default {
async fetch(request, env) {
const corsHeaders = {
"Access-Control-Allow-Origin": "*", // Allow all origins
"Access-Control-Allow-Methods": "POST, OPTIONS", // Allow POST and OPTIONS methods
"Access-Control-Allow-Headers": "Content-Type", // Allow specific headers
};
if (request.method === 'OPTIONS') {
// Handle CORS preflight requests
return new Response(null, {
headers: corsHeaders,
status: 204, // No content
});
}
if (request.method === 'POST') {
// Parse the incoming request body
const requestBody = await request.json();
const eventType = requestBody.eventType || 'unknown_event';
const url = requestBody.url || 'unknown_url';
// Log the event using the Workers Analytics Engine
await env.ANALYTICS.writeDataPoint({
blobs: [eventType, url],
indexes: [eventType],
tags: [url],
});
return new Response("Event logged successfully!", { status: 200 });
} else {
return new Response("Method Not Allowed", { status: 405 });
}
}
};export default {
async fetch(request, env) {
const corsHeaders = {
"Access-Control-Allow-Origin": "*", // Allow all origins
"Access-Control-Allow-Methods": "POST, OPTIONS", // Allow POST and OPTIONS methods
"Access-Control-Allow-Headers": "Content-Type", // Allow specific headers
};
if (request.method === 'OPTIONS') {
// Handle CORS preflight requests
return new Response(null, {
headers: corsHeaders,
status: 204, // No content
});
}
if (request.method === 'POST') {
let requestBody;
try {
requestBody = await request.json(); // Try parsing the JSON
} catch (error) {
return new Response("Invalid JSON", { status: 400 });
}
const eventType = requestBody.eventType || 'unknown_event';
const url = requestBody.url || 'unknown_url';
// Log the event using the Workers Analytics Engine
env.ANALYTICS.writeDataPoint({
blobs: [eventType, url],
indexes: [eventType]
});
return new Response("Event logged successfully!", { status: 200 });
} else {
return new Response("Method Not Allowed", { status: 405 });
}
}
};export const logEvent = async (eventType) => {
try {
const workerUrl = "https://event-tracking-worker.<account>.workers.dev/";
const response = await fetch(workerUrl, {
method: "POST",
headers: {
"Content-Type": "application/json",
},
body: JSON.stringify({
eventType: eventType,
url: window.location.href,
}),
});
if (!response.ok) {
console.error("Failed to log event", response.statusText);
}
} catch (error) {
console.error("Error logging event:", error);
}
};