Please help, proxy server not working on deployement

const express = require("express");
const router = express.Router();

router.get("/movies", (req, res) => {
  try {
    fetch(
      `https://api.themoviedb.org/3/movie/now_playing?api_key=${process.env.MOVIE_API_KEY}&language=en-US&page=1&region=GB`
    )
      .then((res) => res.json())
      .then((data) => res.status(200).json(data));
  } catch (err) {
    res.status(500).json(err);
  }
});

router.get("/hello", (req, res) => {
  res.send("<h1>Hello</h1>");
});

module.exports = router;

Trying to hide my API key using back-end server as a relay. However after deployment when I go to the endpoint ending with /movies, just an empty object {} is returned. When I go to the test endpoint ending with /hello, it is working perfectly. The endpoint /movies is working fine locally but not on deployment. Please help how I can rectify this.

Hi Akash,

Could you add some additional logging to your application for debugging purposes, then check for service logs for clues? For instance, make sure you have the correct API key, and ensure your response from API looks the way you expect it to etc.

Regards,

Matt

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.