Q:

Why is Cors blocking my request to my Api? 

I am developing a project and I need to access to a Api I developed

const endpoint = 'localhost:3000/api/v1/';
const httpOptions = {
  headers: new HttpHeaders({
    'Content-Type': 'application/json',
  }),
};

@Injectable({
  providedIn: 'root',
})
export class RestService {
  constructor(private http: HttpClient) {}

  private extractData(res: Response) {
    let body = res;
    return body || {};
  }

  getRequest(id: String): Observable<Request> {
    return this.http.get<Request>(endpoint + 'request/' + id, httpOptions);
  }

I already gave the permissions so that I can access it but I am getting this error
ccess to XMLHttpRequest at 'localhost:3000/api/v1/request/5ec3fbd84fe7bf4aa8d48b39' from origin 'http://localhost:4200' has been blocked by CORS policy: Cross origin requests are only supported for protocol schemes: http, data, chrome, chrome-extension, https. 

Here it is the permissions:
app.use(
  cors({
    credentials: true,
    origin: "http://localhost:4200",
  })
);

Found the solution.  Endpoint should be  'http://localhost:3000/api/v1/'

A:

The error message mentions the invalid scheme for the request. Try adding 'http' to your endpoint
const endpoint = 'http://localhost:3000/api/v1/';

