[@react-router/serve] Serve additional files during npm run dev
.
#13088
Unanswered
Danielku15
asked this question in
Q&A
Replies: 0 comments
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
-
My usecase might be a bit special but I still hope react-router 7 can serve my needs.
I want to use react-router as framework for a "development playground" / "kitchen sink". During development of my library the playground/kitchen-sink can be used for different sort of tests and debugging needs. Here comes the challenge: The playground needs access to a bunch of files within the development workspace like test files to load.
How can I configure react-router to delegate HTTP requests to some custom handlers so I can process and serve the HTTP response. My two use-cases are:
a) I need to serve static files with the correct mime-types on a given route pattern. e.g.
/test-data/{catchall}
should serve any file from<repository-root>/assets/test
. With this I want to serve any test files needed for fiddling with my library.b) I need two API calls which I can call from my react app. In the first one I want to crawl some folders to visualize test results (snapshot diffs). In the second one I want to allow "accepting" a test results.
It would be quite easy if I can somehow register custom express middlewares but
@react-router/serve
seem to have no callback for this.An important note: I currently have disabled SSR because I want the main application logic to run inside the browser.
What's the correct way to tackle this in react-router?
Beta Was this translation helpful? Give feedback.
All reactions