Local Testing: 405 Error When Fetching From Frontend
Hi, I am trying to test my handler function by fetching data with my frontend (running on localhost:3000). I am running the local RunPod test server (FastAPI) locally and am trying to make requests to it. However, I keep running into a 405 error. My curl requests are working great; however, I need to test my backend from the frontend. I can't find documentation that demonstrates how I can allow requests from localhost:3000 -- normally I would just add a relaxed CORS policy, but I am not sure how to do that with RunPod. I have tried running quite a few different fetch requests, including with my API key, but nothing is working. For reference, here is what I am currently doing on my Next.js frontend:
const header_data = {
input: {
subjob: "root",
},
};
const response = await fetch("http://localhost:8000/run", {
method: "POST",
headers: {
accept: "application/json",
"content-type": "application/json",
authorization:
${RUNPOD_API_KEY}
,
},
body: JSON.stringify(header_data),
});
Here's the error message: [Error] Fetch API cannot load http://localhost:8000/run due to access control checks.
Any help would be greatly appreciated. If there is any further documentation that you can point me to, that could also be quite useful.
Thanks so much (in advance) for your help!0 Replies