Closed tkosci closed 2 years ago
Hi, are you on *nix? If so, always use single quotes as double-quotes have special meaning with strings that contain $
(variable expansion)..
try this instead (no double quotes)
ws --port 8080 --spa index.html --directory build --rewrite '/api/(.*) -> http://localhost:5000/api/$1' --verbose.include middleware.rewrite
the clue was in your verbose output.. I could see the from
string was set correctly but the middleware had not received the full to
string (missing $1
at the end)
{
'middleware.rewrite.config': {
rewrite: [ { from: '/api/(.*)', to: 'http://localhost:5000/api/' } ]
}
}
Thank you, that fixed it for me! It was the double quotes, now the dollar sign symbol with number is visible in the verbose output as well.
Hello,
I am facing issue with rewrite wildcard.
When I use:
ws --port 8080 --spa index.html --directory build --rewrite "/api/(.*) -> http://localhost:5000/api/$1" --verbose.include middleware.rewrite
The urls do not match as seen in screenshot below:
However, in debugging tool the wildcard matches just fine:
npx lws-rewrite '/api/(.*)' 'http://localhost:5000/api/$1' '/api/count_data/'
->http://localhost:5000/api/count_data/
Any idea what is the issue here? Thanks