Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feature request: API for adding handler to http server #7

Open
mikeal opened this issue Apr 4, 2020 · 2 comments
Open

feature request: API for adding handler to http server #7

mikeal opened this issue Apr 4, 2020 · 2 comments

Comments

@mikeal
Copy link
Contributor

mikeal commented Apr 4, 2020

I need a way to add code to the http server that serves up the static assets so that I don’t step on any CORS problems. Not sure the best way to go about it so I figured I’d log an issue.

@rvagg
Copy link
Owner

rvagg commented Apr 6, 2020

I have a memory of doing this for one of my projects that uses polendina but I can't find it! Maybe I undid it because it was a complicated mess.

One solution is to use webpack's lazy require resolution, check out this magic: https://github.com/rvagg/js-zcash-block/blob/master/test/browser.js

require.context() lets me get a directory listing using a regex, see https://webpack.js.org/guides/dependency-management/#requirecontext, then the dynamic import function does some fancy work to make the possible files available for me in the bundle. The bundle itself is pretty heavy because of this but it's all there when I need it for the tests, no need to load stuff afterward.

But that's not going to work if you have a more complicated workflow. I'll try and get my mind back to when I was considering alternatives to this, I think it was about giving the user the control over the web server and just asking for where to load files from.

@mikeal
Copy link
Contributor Author

mikeal commented Apr 7, 2020

For my use case, I need to attach an HTTP API implemented in Node.js, not additional static files, so these won’t for me.

I have both the client and server implementation in the same project and I want to test the client in the browser against the server implementation on localhost.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants