serve icon indicating copy to clipboard operation
serve copied to clipboard

Rewrites not being applied.

Open nemonemi opened this issue 3 years ago • 6 comments

I have a use case where the libraries that are being produced by the monorepo (NX) have different base paths. I would like to use this library to serve locally those builds for debugging. However, right now if I just serve the folder of the build it doesn't work. I have to change the content of the base tag manually from to .

I would like to handle this as a part of the serve config.

Here's the way I call the serve and my setup: serve -s ./dist/apps/thing-form -c ./serve.json

{
  "rewrites": [{ "source": "/thing/form", "destination": "/dist/apps/thing-form/index.html" }]
}

The application is a react spa so what should be resolved are static resources. The inner routing is handled by the application.

With this setup and the way I call it, I don't see any effect of the serve.json file.

nemonemi avatar Feb 25 '21 17:02 nemonemi

I have the same problem, have you found a solution

danierdev avatar Mar 15 '21 16:03 danierdev

Unfortunately, I have not. This is still on hold for me.

nemonemi avatar Mar 15 '21 16:03 nemonemi

I also have this issue.

Marviel avatar Mar 26 '21 18:03 Marviel

I figured it out. Basically, if you are using the -s argument to specify the directory to run within, the path rewriting will not work.

However, if you cd to the directory you wish to serve, and then run the serve command, the rewrites will work as expected.

TL;DR:

Instead of This:

yarn run serve -s [DIRNAME] ...

Do This:

cd [DIRNAME] && yarn run serve ...

Marviel avatar Mar 26 '21 19:03 Marviel

Maintainers, I think we could really use some dev lift on this one -- as it's not made clear that using the -s argument will break the serve.json file default behavior.

I'd also be happy to take a look myself if you can point me to where the issue likely lies :)

Marviel avatar Mar 26 '21 19:03 Marviel

fwiw, it doesn't look like the -s flag is being used correctly.. which is shorthand for --single.. which is a boolean that causes all requests to redirect to the virtual pathname: /index.html

warren-bank avatar Feb 11 '22 01:02 warren-bank