Closed simplenotezy closed 3 years ago
Yes, the --rewrite
option is for URL rewriting.. So if a client requests index.html
you could instead, with a rewrite rule, return new-index.html
(for example).
There is a useful debugging tool to help build rewrite expressions: https://github.com/lwsjs/local-web-server/wiki/How-to-rewrite-URLs-to-local-or-remote-destinations#debugging
however, I don't think URL rewriting is what you're trying to achieve here - sounds like you want ws
to edit the body of any HTML file containing a particular text string (in your case a URL).. ordinarily, a website would have a configuration file (or similar) which you could edit to "point" the web app at a different target servers.. I'm assuming you don't have this config file so yes, you would need a custom middleware to scan and edit the HTML files returned..
I will respond to your seperate issue on this topic..
@75lb OK. I see. Yes that's exactly what I need, I need to rewrite the body raw HTML, as the build process takes ~30 minutes, and before running my deploy script, I'd like to run some tests. But I don't want to run the tests against the "production" URLs, so I need to rewrite this.
Looking forward to your reply, as I am more than eager to proceed with this 😊
Really cool repo! Might just be what I am looking for.
I am in need of this repo, since I'd like cypress.io to test the static site after it has been built/compiled, but before publishing to production. The issue is that the /dist/ folder contains absolute URLs to the production site, and I'd like to rewrite these URLs from "https://myproductionsite.com" to "https://localhost:8000".
I have tried this with the --rewrite option, but not sure if that's what it is meant for.
This doesn't seem to work:
(jwr.test is representing the production URL in this test case)