Empresas
Empleos
  • Sobre nosotros
  • Soluciones
    • Publicación de vacantes
      Publica tu vacante y recibe candidatos calificados en 48h.
    • Evaluación de candidatos
      500+ pruebas técnicas y psicológicas, más anti-fraude.
    • Headhunting
      Búsqueda ejecutiva a la medida de principio a fin.
    • Nómina + EOR
      Dispersión de nómina y EOR en más de 15 países de LATAM.
  • Precios
  • Empleos

0

317
Vistas
express vhost doesn't proxy the cdn in localhost

I was trying to proxy a cdn url (https://cdn.somedomain.com/) in localhost using vhost middleware but it gives me some strange error.

Before going into the issue, I have been trying to access a cdn url which produces a CORS error where the resource doesn't allow wildcard (*), I need to match the domain name to fix that. So, I tried aliasing the domain name to the local IP address in /etc/hosts/.

Something like this:

127.0.0.1 cdn.somedomain.com.local

Here is my server configuration file:

const express = require('express');
const vhost = require('vhost');
...
const app = express();
const { cdn } = require('./cdn.js');
app.use(vhost('cdn.somedomain.com.local', cdn));

The last line complains about a compilation error:

No overload matches this call.

The last overload gave the following error. Argument of type 'Function' is not assignable to parameter of type 'PathParams'. Type 'Function' is missing the following properties from type '(string | RegExp)[]': pop, push, concat, join, and 27 more.

cdn.js

const express = require('express');
const cors = require('cors');
const path = require('path');

const cdn = express();
cdn.use(cors());
cdn.use(express.static(path.resolve(__dirname, '../static-host/')));

module.exports = { cdn };

When I run the app, I get a 404 and the request url looks something like this:

http://cdn.somedomain.com.local:3000/

Target resource should be something like this:

https://cdn.somedomain.com/

I have been trying a couple of other options, none of them seems to work as expected.

Appreciate any help in this matter!

about 4 years ago · Juan Pablo Isaza
Responde la pregunta
Encuentra empleos remotos

¡Descubre la nueva forma de encontrar empleo!

Top de empleos
Top categorías de empleo
Empresas
Publicar vacante Precios Comercial
Legal
Términos y condiciones Política de privacidad
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomiéndame algunas ofertas
Necesito ayuda