简体   繁体   English

指定根文件夹express-http-proxy

[英]Specifying root folder express-http-proxy

I am using express-http-proxy 我正在使用express-http-proxy

basic setup 基本设置

const express = require('express');
const proxy = require('express-http-proxy');

app.use('/api/', proxy(`http://api-url/`));

app.listen(3000);

works as expected, except static files. 可以正常工作,除了静态文件。 they are point to proxy host instead of proxy route 它们指向代理主机而不是代理路由

http://localhost:3000/bundle.js

it should be 它应该是

http://localhost:3000/api/bundle.js

I am assuming that bundle.js is a file hosted on the proxy host. 我假设bundle.js是代理主机上托管的文件。 Wherever it is referenced you may have to use relative paths so that it does not go to the root of the url. 无论在何处引用它,您都可能必须使用相对路径,这样它才不会到达url的根目录。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM