Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

CORS error while trying to register #299

Open
Elie-Soued opened this issue Dec 6, 2024 · 0 comments
Open

CORS error while trying to register #299

Elie-Soued opened this issue Dec 6, 2024 · 0 comments

Comments

@Elie-Soued
Copy link

Elie-Soued commented Dec 6, 2024

Steps to reproduce the issue:
1- Clone repo
2-Run yarn install
3- run ng serve
4-go to the signup section
5-Fill the section with username, email and password
6- click the submit button

Actual
I am getting the below error:
Access to XMLHttpRequest at 'https://api.realworld.io/api/users' from origin 'http://localhost:4200' has been blocked by CORS policy: Response to preflight request doesn't pass access control check: No 'Access-Control-Allow-Origin' header is present on the requested resource.

Expected
I can register.

More notes:
I have added the "Access-Control-Allow-Origin" header in the call but I am still getting the same error.

  register(credentials: {
    username: string;
    email: string;
    password: string;
  }): Observable<{ user: User }> {
    
    return this.http
      .post<{ user: User }>("/users", { user: credentials },{headers : {"Access-Control-Allow-Origin" : "*"}})
      .pipe(tap(({ user }) => this.setAuth(user)));
  }

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant