streamerd
streamerd
Explore posts from servers
RRailway
Created by streamerd on 7/14/2024 in #✋|help
method not allowed (python/fastapi)
Hello, I've just tested python app locally and it was working alright. Now deployed it successfully and the port was detected from dockerfile, all good. But then checking the deploy logs, I see a redirect on my post then hitting to get and throwing a method not allowed err and idk why:
INFO: 100.64.0.3:30552 - "POST /detect_faces HTTP/1.1" 307 Temporary Redirect
INFO: 100.64.0.2:14540 - "GET /detect_faces/ HTTP/1.1" 405 Method Not Allowed
INFO: 100.64.0.3:30552 - "POST /detect_faces HTTP/1.1" 307 Temporary Redirect
INFO: 100.64.0.2:14540 - "GET /detect_faces/ HTTP/1.1" 405 Method Not Allowed
Project: 56a9f5e1-f542-4450-9860-623ac58b1b47 endpoint: https://face-detection-production-76b4.up.railway.app/detect_faces to reproduce, send a post request to above endpoint with a multipart/form-data, body being a form data with key file and type file, then selected an image file from your computer. here's the code: https://github.com/stateful-art/face-detection
19 replies
RRailway
Created by streamerd on 6/7/2024 in #✋|help
Cors problem in deployment (react + go)
Helo people, I'm aware there's been bunch of similar issue presented and resolved, yet I did all I could and still no luck. project ID: 443e27d8-9cdf-478d-a4ec-c846823facf8 I'm getting
Cross-Origin Request Blocked: The Same Origin Policy disallows reading the remote resource at https://api.diplomacy.network/peace. (Reason: CORS header ‘Access-Control-Allow-Origin’ missing). Status code: 405.

Cross-Origin Request Blocked: The Same Origin Policy disallows reading the remote resource at https://api.diplomacy.network/peace. (Reason: CORS request did not succeed). Status code: (null)..
Cross-Origin Request Blocked: The Same Origin Policy disallows reading the remote resource at https://api.diplomacy.network/peace. (Reason: CORS header ‘Access-Control-Allow-Origin’ missing). Status code: 405.

Cross-Origin Request Blocked: The Same Origin Policy disallows reading the remote resource at https://api.diplomacy.network/peace. (Reason: CORS request did not succeed). Status code: (null)..
I got below config in go:
corsMiddleware := handlers.CORS(
handlers.AllowedOrigins([]string{
"https://diplomacy.network",
"http://localhost:3000",
}),
handlers.AllowedMethods([]string{
http.MethodGet, http.MethodPost, http.MethodPut, http.MethodDelete, http.MethodOptions, // Specify allowed methods
}),
handlers.AllowedHeaders([]string{
"Content-Type", "Access-Control-Allow-Origin",
}),
)
corsMiddleware := handlers.CORS(
handlers.AllowedOrigins([]string{
"https://diplomacy.network",
"http://localhost:3000",
}),
handlers.AllowedMethods([]string{
http.MethodGet, http.MethodPost, http.MethodPut, http.MethodDelete, http.MethodOptions, // Specify allowed methods
}),
handlers.AllowedHeaders([]string{
"Content-Type", "Access-Control-Allow-Origin",
}),
)
and making request like below from the react: (to https url)
try {
const apiUrl = `${process.env.NEXT_PUBLIC_API_URL}/peace`;
console.log("API URL:", apiUrl);
await axios.post(apiUrl, {
peacemakers: [updatedPeacemaker, peacemakers[1]],
});
alert("Update successful!");
} catch (error) {
console.error("Error sending POST request:", error);
alert("Failed to update.");
}
try {
const apiUrl = `${process.env.NEXT_PUBLIC_API_URL}/peace`;
console.log("API URL:", apiUrl);
await axios.post(apiUrl, {
peacemakers: [updatedPeacemaker, peacemakers[1]],
});
alert("Update successful!");
} catch (error) {
console.error("Error sending POST request:", error);
alert("Failed to update.");
}
23 replies