Getting 502 bad gateway error and CORS problem on Wanderlust project

I am working on this Wanderlust project that’s included in the Full-stack path. I am on step 13 and I am getting this error in the console, despite my first fetch in step 12 working just fine (I saw the response logged in the console).

Access to fetch at '' from origin '' has been blocked by CORS policy: No 'Access-Control-Allow-Origin' header is present on the requested resource. If an opaque response serves your needs, set the request's mode to 'no-cors' to fetch the resource with CORS disabled.


What can I do here? Here’s my code.

const url = new URL('');
const options = {
  method: 'GET',
  headers: {
    Accept: 'application/json',
    Authorization: foursquareKey

// Add AJAX functions here:
const getPlaces = async () => {
  const city = $input.val();
  const urlToFetch = new URL(`${url}${city}&limit=10`);
  try {
    const response = await fetch(urlToFetch, options);
    if (response.ok) {
      const jsonResponse = await response.json();
  } catch(error) {


Thanks in advance for your help!

The 502 (Bad Gateway) status code indicates that the server while acting as a gateway or proxy, received an invalid response from an inbound server it accessed while attempting to fulfill the request. The “proxy server” is a system or router that acts as a gateway between your computer and the internet.

How to fix?

Perform a hard-refresh in your browser. On Macs, this is done by pressing Cmd + Shift + R.

If you are surfing the Web and see this problem for all Web sites you try to visit, then either 1) your ISP has a major equipment failure/overload or 2) there is something wrong with your internal Internet connection e.g. your firewall is not functioning correctly. In the first case, only your ISP can help you. In the second case, you need to fix whatever it is that is preventing you reaching the Internet.

This problem is due to poor IP communication between back-end computers, possibly including the Web server at the site you are trying to visit. Before analysing this problem, you should clear your browser cache completely.

Finally, restart your computer/networking equipment. Some temporary issues with your computer and how it’s connecting to your network could be causing 502 Bad gateway errors, especially if you’re seeing the error on more than one website. In these cases, a restart would help.