-
-
Notifications
You must be signed in to change notification settings - Fork 1.1k
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: allow server to be sub app in express #1448
Comments
For the bring-your-own-express, please see #1156 and #1141 someone started that but did not have the time. This is still a wanted feature so a PR is welcomed. |
I created issue for CORS with PR. I will create PR for bring-your-own-express feature but I will be without computer from this Thursday to up to two weeks. I'm not sure if I will be able to prepare PR before Thursday. |
Closes pubkey#1448 allow server to be sub app in express
@dstudzinski hi. any update on this? |
@pubkey Hi, yes, I'm back online and I plan to work on it and finish it tomorrow/during weekend |
I pushed all changes (I can't find typings for server plugin) but I still have problems with failing tests. New test which I added creates Express app and Express can be started only in node. Could you please help/advise me how to solve it? Should I eg reconfigure tests and create new tests file for Node only testing? |
You can prevent test from running in the browser by checking |
Ok the problem was in import not in test itself. I moved express import after |
Case
Feature request
Issue
Allow server to be part of bigger express application by making changes which allow to use server as a sub app.
Info
Code
First step is to change code which detects url as an url to collection.
In
tunnelCollectionPath
https://github.com/pubkey/rxdb/blob/master/src/plugins/server.js#L58(req.baseUrl === collectionPath)
should be changed to something like(req.baseUrl.endsWith(collectionPath))
Another way to achieve this is to add new option to server like
prefix
which will allow to configure where app is mountedSecond step is to add some parameter to allow constructing app without starting it (calling listen). The app object is all what we need.
Currently I did change described in step one then I did something like this:
What do you think about such change?
It for sure helps to construct more complicated mocks with eg auth and it's step forward to be able to use rxdb server as an embedded server for small apps.
BTW: I did this example when I got
Access to fetch at 'URI1' from origin 'URI2' has been blocked by CORS policy: The value of the 'Access-Control-Allow-Origin' header in the response must not be the wildcard '*' when the request's credentials mode is 'include'.
error and I wanted to add my own middleware to setup CORS.
I did what I described above, disabled cors in server options (important) and added this (the code is not mine I believe I found it here https://stackoverflow.com/a/52210785 or from similar topic):
which solved my problem
Should I create issue related to CORS?
The text was updated successfully, but these errors were encountered: