Skip to content
Back

Please help I'm still getting CORS error of Appwrite instead enable platform hostname: localhost.

  • 0
  • Web
Abhishek Gupta
9 Oct, 2023, 17:03

I'm following one Youtuber

TL;DR
The user is experiencing a CORS error with Appwrite when trying to enable the platform hostname as localhost. They have provided some code for a signup function and are asking for help. Another user suggests wrapping the code in backticks for better formatting. The signup form is not appearing even after making some changes. It is suggested that the error is due to the user not being logged in and should not cause any problems. They are advised to try using the suggested code to simplify the check for logged-in users. It is mentioned that Appwrite might be easy to understand for users with basic or intermediate JavaScript knowledge. The user is asked to clarify their goal
Abhishek Gupta
9 Oct, 2023, 17:03

which made this project

D5
9 Oct, 2023, 17:03

So basically you're copypasting?

Abhishek Gupta
9 Oct, 2023, 17:04

not understanding also

Abhishek Gupta
9 Oct, 2023, 17:04

because I want to learn.

Abhishek Gupta
9 Oct, 2023, 17:04

appwrite

D5
9 Oct, 2023, 17:04

Tell me what do you want to achieve, the code you sent deppends on another file

D5
9 Oct, 2023, 17:04

If you have basic/intermeddiate js knowledge appwrite will be really easy to understand for you

Abhishek Gupta
9 Oct, 2023, 17:06

I had sended you auth.js file code previous

D5
9 Oct, 2023, 17:07

The code you sent seems to check if the user is or not logged in, so that part should be this way simplified without overcomplicating:

TypeScript
try{

  account.get();
  
//here you can make what you want if user is logged in
console.log("the user is already logged in");

 }catch(error){

console.log("the user is logged out");
}```
D5
9 Oct, 2023, 17:09

Sincerely that video seems to do things "in the pro way" so they're more difficult to understand for beginners

Abhishek Gupta
9 Oct, 2023, 17:10

async getCurrentUser() { try { account.get() console.log("the user is already logged in"); } catch (error) { console.log("Appwrite service :: getCurrentUser :: error", error) }

TypeScript
    return null;
}
Abhishek Gupta
9 Oct, 2023, 17:10

can I try this?

D5
9 Oct, 2023, 17:10

After taking a look into this, seems everything is correct. You're getting the error because the user is not logged in, so it should not be any problem or cause any inconveniences

D5
9 Oct, 2023, 17:10

Yes

Abhishek Gupta
9 Oct, 2023, 17:13

now no error but signup form is not coming?

Abhishek Gupta
9 Oct, 2023, 17:13

on clickin signup button

D5
9 Oct, 2023, 17:13

What's the signup button code?

Abhishek Gupta
9 Oct, 2023, 17:16

function Signup() { const navigate = useNavigate() const [error, setError] = useState("") const dispatch = useDispatch() const {register, handleSubmit} = useForm()

TypeScript
const create = async (data) => {
    setError("")
    try {
      const userData = await authService.createAccount(data)
      if(userData) {
       const userData = await authService.
       getCurrentUser()
       if(userData) dispatch(login(userData))
       navigate("/")
      } 
    } catch (error) {
        setError(error.message)
    }
}
Abhishek Gupta
9 Oct, 2023, 17:19

is this correct?

Drake
9 Oct, 2023, 17:45

FYI, it's best to wrap code in backticks to format a bit nicer. You can use 1 backtick for inline code (https://www.markdownguide.org/basic-syntax/#code) and 3 backticks for multiline code (https://www.markdownguide.org/extended-syntax/#syntax-highlighting.

omzi
9 Oct, 2023, 20:31

Bro literally tagged him again πŸ’€

omzi
9 Oct, 2023, 20:32

I'm sorry on his behalf Steven πŸ˜…

D5
9 Oct, 2023, 21:01

Not sure what this does, this is the continuation of the first code you sent?

Abhishek Gupta
11 Oct, 2023, 05:27

it's signup function code

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