Snippet API Issue (down?)
API Request Failed: PUT /api/v4/zones/493ab3fa5d780aa7653c8f028060642c/snippets/cors_yt (503)
PUT answer: upstream connect error or disconnect/reset before headers. reset reason: connection termination
Put Request (in which the config is going though):
------geckoformboundary7d56fe3f568fb424b753e5424761e3db
Content-Disposition: form-data; name="metadata"
{"compatibility_date":"2023-01-31","bindings":[],"main_module":"snippet.js"}
------geckoformboundary7d56fe3f568fb424b753e5424761e3db
Content-Disposition: form-data; name="snippet.js"; filename="snippet.js"
Content-Type: application/javascript+module
const corsHeaders = {
"Access-Control-Allow-Origin": "*",
"Access-Control-Allow-Methods": "GET,POST,OPTIONS,HEAD,PATCH,PUT,DELETE",
"Access-Control-Allow-Headers": "User-Agent,Authorization,Content-Type",
"Access-Control-Allow-Credentials": "true",
"Cross-Origin-Resource-Policy": "cross-origin"
};
export default {
async fetch(request) {
// Handle preflight OPTIONS request
if (request.method === "OPTIONS") {
return new Response(null, {
status: 204,
headers: corsHeaders
});
}
try {
// Forward the request to your backend
const response = await fetch(request);
// Clone the response so we can modify headers
const newResponse = new Response(response.body, response);
// Add CORS headers to the response
Object.entries(corsHeaders).forEach(([key, value]) => {
newResponse.headers.set(key, value);
});
return newResponse;
} catch (error) {
return new Response(`Error: ${error.message}`, { status: 500 });
}
}
};
------geckoformboundary7d56fe3f568fb424b753e5424761e3db--
------geckoformboundary7d56fe3f568fb424b753e5424761e3db
Content-Disposition: form-data; name="metadata"
{"compatibility_date":"2023-01-31","bindings":[],"main_module":"snippet.js"}
------geckoformboundary7d56fe3f568fb424b753e5424761e3db
Content-Disposition: form-data; name="snippet.js"; filename="snippet.js"
Content-Type: application/javascript+module
const corsHeaders = {
"Access-Control-Allow-Origin": "*",
"Access-Control-Allow-Methods": "GET,POST,OPTIONS,HEAD,PATCH,PUT,DELETE",
"Access-Control-Allow-Headers": "User-Agent,Authorization,Content-Type",
"Access-Control-Allow-Credentials": "true",
"Cross-Origin-Resource-Policy": "cross-origin"
};
export default {
async fetch(request) {
// Handle preflight OPTIONS request
if (request.method === "OPTIONS") {
return new Response(null, {
status: 204,
headers: corsHeaders
});
}
try {
// Forward the request to your backend
const response = await fetch(request);
// Clone the response so we can modify headers
const newResponse = new Response(response.body, response);
// Add CORS headers to the response
Object.entries(corsHeaders).forEach(([key, value]) => {
newResponse.headers.set(key, value);
});
return newResponse;
} catch (error) {
return new Response(`Error: ${error.message}`, { status: 500 });
}
}
};
------geckoformboundary7d56fe3f568fb424b753e5424761e3db--
1 Reply
I met same issue
I think it is fixed