I am working on an Angular app, where I get a list of albums and photos using the Flickr API. Below is the serviced I created to consume the Flickr API
import { Injectable } from '@angular/core';
import { HttpClient, HttpHeaders } from '@angular/common/http';
import { GlobalsService } from './globals.service';
import * as Rx from 'rxjs';
interface Response {
  photosets: PhotoSets;
}
interface PhotoSets {
  page: number;
  pages: number;
  photoset: PhotoSet[];
  length: number;
}
interface PhotoSet {
  id: string;
  description: String;
  title: String;
}
interface String {
  _content: string;
}
interface PhotoSetByIds {
  photoset: PhotoSetById;
}
interface PhotoSetById {
  id: string;
  owner: string;
  ownername: string;
  page: number;
  pages: number;
  per_page: number;
  perpage: number;
  photo: Photo[];
  primary: string;
  title: string;
  total: string;
}
interface Photo {
  length: number;
  farm: number;
  id: string;
  isfamily: number;
  isfriend: number;
  ispramy: string;
  ispublic: number;
  secret: string;
  server: string;
  title: string;
}
@Injectable({
  providedIn: 'root'
})
export class FlickrServiceService {
  constructor(private http: HttpClient, private globals: GlobalsService) {
  }
  getPhotoSets() {
    return this.http.get<Response>(
      'https://api.flickr.com/services/rest/?method=flickr.photosets.getList&api_key=' +
        this.globals.apiKey +
        '&user_id=' +
        this.globals.userId +
        '&format=json&nojsoncallback=1'
    );
  }
  getPhotos(photosetId: any) {
    return this.http.get<PhotoSetByIds>(
      'https://api.flickr.com/services/rest/?method=flickr.photosets.getPhotos&api_key=' +
        this.globals.apiKey +
        '&photoset_id=' +
        photosetId +
        '&user_id=' +
        this.globals.userId +
        '&format=json&nojsoncallback=1'
    );
  }
}
The thing is, I get the following CORS error when I try to get something:
Access to XMLHttpRequest at 'https://api.flickr.com/services/rest/?method=flickr.photosets.getList&api_key=&user_id=&format=json&nojsoncallback=1' from origin 'http://localhost:4200' has been blocked by CORS policy: Request header field authorization is not allowed by Access-Control-Allow-Headers in preflight response. core.js:4002 ERROR HttpErrorResponse {headers: HttpHeaders, status: 0, statusText: "Unknown Error", url: "https://api.flickr.com/services/rest/?method=flick…ser_id=170538248@N08&format=json&nojsoncallback=1", ok: false, …}
I still don't know how to solve this problem. Any help? Thank you!