Back

CORS issue

  • 0
  • Web
REAPER
30 Jan, 2024, 18:09

@D5

I am facing this CORS error. I am using Vite as my frontend.

I tried setting up the Hostname to localhost and to * but still didnt work.

If anyone can check it out it would be great... thank you !

TL;DR
Developers are experiencing a CORS issue while using Vite as their frontend. They have tried setting the hostname to `localhost` and `*`, but the issue persists. No solution is provided in the thread.
D5
30 Jan, 2024, 18:10

Thanks for creating the post! Do you have any other errors appart from this one?

D5
30 Jan, 2024, 18:16

And what's the code?

REAPER
30 Jan, 2024, 18:21

i just started the project :p

REAPER
30 Jan, 2024, 18:21

i will provide it one sec

REAPER
30 Jan, 2024, 18:26

@D5 i dont think i can provide the code because of my extensive folder / file structuring.

D5
30 Jan, 2024, 18:26

Not everything, only the appwrite code fragment

REAPER
30 Jan, 2024, 18:26

config.ts

TypeScript
import { Client, Account, Databases, Storage, Avatars } from 'appwrite';

export const appwriteConfig = {
    projectId: import.meta.env.VITE_APPWRITE_PROJECT_ID,
    url: import.meta.env.VITE_APPWRITE_URL
}

export const client = new Client();

client.setProject(appwriteConfig.projectId);
client.setEndpoint(appwriteConfig.url);

console.log("appwriteConfig.projectId", appwriteConfig.projectId)
console.log("appwriteConfig.url", appwriteConfig.url)


export const account = new Account(client);
export const databases = new Databases(client);
export const storage = new Storage(client);
export const avatars = new Avatars(client);
REAPER
30 Jan, 2024, 18:30

Signupform.ts

TypeScript
const SignupForm = () => {
  
  const isLoading = false;
  
   const form = useForm<z.infer<typeof SignupValidation>>({
    resolver: zodResolver(SignupValidation),
    defaultValues: {
      name: "",
      username: "",
      email: "",
      password: ""
    },
  })
 
  
  async function onSubmit(values: z.infer<typeof SignupValidation>) {
    const newUser = await createUserAccount(values)
    console.log(newUser)
  }


<form onSubmit={form.handleSubmit(onSubmit)} className="flex flex-col gap-5 w-full mt-4`">
</form>

im using **shadcn ** btw (it helps with some ui / forms ... )

REAPER
30 Jan, 2024, 18:30

@D5 good enough?

D5
30 Jan, 2024, 18:46

Yes

D5
30 Jan, 2024, 18:54

Are you sure that the project ID is correct?

D5
30 Jan, 2024, 18:56

Try setting client this way:

TypeScript
const client = new Client();
D5
30 Jan, 2024, 18:57

Also, could you please share the code for account creation?

Reply

Reply to this thread by joining our Discord

Reply on Discord

Need support?

Join our Discord

Get community support by joining our Discord server.

Join Discord

Get premium support

Join Appwrite Pro and get email support from our team.

Learn more