Home > Mobile >  Node JS post API endpoint not recognized in front end
Node JS post API endpoint not recognized in front end

Time:05-03

I'm trying to make a post request using appwrite SDK in Node JS express and Vue JS. The SDK requires me to create an api post request to create new storage bucket in appwrite. The Screenshot of the error

Something is missing here and I can't really figure it out.

CodePudding user response:

You are making request to localhost:8080 meanwhile your server is running at localhost:3080

I believe your vue is running at port 8080 that's why /v1/storage/buckets gets prefixed by localhost:8080

Try to provide full URL while making request

export async function createBucket() {
  const response = await fetch("localhost:3080/v1/storage/buckets", {
    method: "POST",
  });
  return await response.json();
}

Better way might be to add proxy to automatically redirect request to correct URL, but this should work for now. This article might help with how to setup proxy in vue

  • Related