(edited)
Hello,
Since yesterday, my production application no longer works.
I use Vercel's serverless functions as a proxy for my front-end requests to the TMDB API. This function adds the Bearer token to http headers so that users don't see my API token.
// Vercel serverless function to proxy TMDB API requests
import { createProxyMiddleware } from 'http-proxy-middleware';import type { Request, Response } from 'express';
const apiProxy = createProxyMiddleware({ target: process.env['TMDB_API_URL'], changeOrigin: true, pathRewrite: { '^/api': '', }, onProxyReq: proxyReq => { proxyReq.setHeader( 'Authorization', `Bearer ${process.env['TMDB_API_TOKEN']}` ); },});
export default async function (req: Request<any>, res: Response<any>) { return apiProxy(req, res, () => ({}));}Until yesterday, everything had been running smoothly for over 8 months.
Error logs returned by the proxy function :
[Proxy Response] { statusCode: 403, path: '/configuration', headers: { 'content-type': 'text/plain', 'transfer-encoding': 'chunked', connection: 'close', date: 'Wed, 20 Nov 2024 08:34:23 GMT', server: 'openresty', 'content-encoding': 'gzip', vary: 'Accept-Encoding,accept-encoding, Origin', 'x-cache': 'Error from cloudfront', via: '1.1 b09c8a20b29053a362f3c1085a0f8990.cloudfront.net (CloudFront)', 'x-amz-cf-pop': 'MRS52-P5', 'alt-svc': 'h3=":443"; ma=86400', 'x-amz-cf-id': 'wuVqwl7l58qHOjPJgJOfAgVIy7IMNAVgCnvhFOui9-kgrlbTQO3L9Q==' }}There is a possibility that my Vercel host has been blocked ?
When i try to use TMDB API with postman or with an other proxy there is no problem.
Thanks for helping.