Closed sysmat closed 3 years ago
Hi! There's a test specifically for proxies that's passing fine, this is likely something to do with your configuration/setup, but issues are not the place to debug those.
If you still feel this is a valid problem with proxies, you can submit a minimal reproduction.
import svelte from 'rollup-plugin-svelte';
import commonjs from '@rollup/plugin-commonjs';
import resolve from '@rollup/plugin-node-resolve';
import livereload from 'rollup-plugin-livereload';
import { terser } from 'rollup-plugin-terser';
import serveLocal from 'rollup-plugin-serve'
import sveltePreprocess from 'svelte-preprocess';
import typescript from '@rollup/plugin-typescript';
import css from 'rollup-plugin-css-only';
import dev from 'rollup-plugin-dev'
import replace from '@rollup/plugin-replace'
const production = !process.env.ROLLUP_WATCH;
console.log('production', production);
function serve() {
let server;
function toExit() {
if (server) server.kill(0);
}
return {
writeBundle() {
if (server) return;
server = require('child_process').spawn('npm', ['run', 'start', '--', '--dev'], {
stdio: ['ignore', 'inherit', 'inherit'],
shell: true
});
process.on('SIGTERM', toExit);
process.on('exit', toExit);
}
};
}
export default {
input: 'src/main.ts',
output: {
sourcemap: true,
format: 'iife',
name: 'app',
file: 'public/build/bundle.js'
},
plugins: [
replace({
'process.env.NODE_ENV': JSON.stringify('production')
}),
svelte({
preprocess: sveltePreprocess({ sourceMap: !production }),
compilerOptions: {
// enable run-time checks when not in production
dev: !production
}
}),
// we'll extract any component CSS out into
// a separate file - better for performance
css({ output: 'bundle.css' }),
// If you have external dependencies installed from
// npm, you'll most likely need these plugins. In
// some cases you'll need additional configuration -
// consult the documentation for details:
// https://github.com/rollup/plugins/tree/master/packages/commonjs
resolve({
browser: true,
dedupe: ['svelte']
}),
commonjs(),
typescript({
sourceMap: !production,
inlineSources: !production
}),
!production && livereload('public'),
production && terser(),
dev({
dirs: ['public'],
port: 5000,
host: 'localhost',
proxy: {
'/api/*': 'http://localhost:8080/analizator'
}
})
],
watch: {
clearScreen: false
}
};
"dev": "rollup -c -w",
-> npm run dev
test specifically for proxies
what do you mean by that?
Pasting your Rollup config is not a minimum reproduction. The readme has both an example and a link to further documentation on proxies. I'm closing this as invalid.
Ok I'm reverting it to webpack it is working proxy, non of proxy solution's for rollup seams to work in my case. So the same project is working dev proxy with angular, webpack in dev environment
basuURi=http://localhost:9090/analizator
but only to port 9090const devServer = dev({
dirs: ['public'],
port: 5000,
host: 'localhost',
proxy: {
'/api*': ['http://localhost:9090/analizator', {
https: false, filter: (ctx) => {
console.log('ctx', ctx);
return ctx.method === 'GET';
}
}]
}
});
subdomainOffset: 2, proxy: false
{
request: {
method: 'GET',
url: '/api/queries/',
header: {
host: '127.0.0.1:5000',
connection: 'keep-alive',
'sec-ch-ua': '" Not A;Brand";v="99", "Chromium";v="90", "Google Chrome";v="90"',
'sec-ch-ua-mobile': '?0',
'user-agent': 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/90.0.4430.93 Safari/537.36',
accept: '*/*',
'sec-fetch-site': 'same-origin',
'sec-fetch-mode': 'cors',
'sec-fetch-dest': 'empty',
referer: 'http://127.0.0.1:5000/',
'accept-encoding': 'gzip, deflate, br',
'accept-language': 'en-US,en;q=0.9'
}
},
response: {
status: 404,
message: 'Not Found',
header: [Object: null prototype] {}
},
app: { subdomainOffset: 2, proxy: false, env: 'development' },
originalUrl: '/api/queries/',
req: '<original node req>',
res: '<original node res>',
socket: '<original node socket>'
}
/api/queries/ --proxy--> http://localhost:9090/api/queries/ // this is wrong
// it should send to
/api/queries/ --proxy--> http://localhost:9090/analizator/api/queries/
Most of the proxy's I know from other languages work as mapping 'path1' -> ${baseSecondUri}/path1
I se this lib use koa-better-http-proxy, so bug is in koa-better-http-proxy or this lib not passing proxy args well to koa
http://localhost:8080/analizator/api/version
None of API calls work