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

Please give an example file "routes.json" #7

Open
mtraining-2022 opened this issue Apr 1, 2023 · 1 comment
Open

Please give an example file "routes.json" #7

mtraining-2022 opened this issue Apr 1, 2023 · 1 comment

Comments

@mtraining-2022
Copy link

Please give an example file "routes.json"

@arihav
Copy link

arihav commented Jul 20, 2023

Here's an example of a"routes.json" file:

{
    "rules": [
        {
            "description": "Route all API requests to localhost:3000",
            "from": {
                "host": ".*",
                "path": "^/api(/.*)?$"
            },
            "to": {
                "host": "localhost:3000",
                "path": "$0"
            },
            "public": true
        },
        {
            "description": "Route all other requests to localhost:2222",
            "from": {
                "host": ".*",
                "path": ".*"
            },
            "to": {
                "host": "localhost:2222",
                "path": "$0"
            },
            "public": true
        }
    ]
}

Explanation:

The first rule is designed to handle all requests with paths starting with "/api/". It uses regular expressions to match paths that start with "/api/" followed by optional additional segments. For these requests, the traffic is directed to "localhost:3000" while preserving the original path.
The second rule is a catch-all for all other requests that do not match the first rule. It will handle requests with any path and direct them to "localhost:2222" while preserving the original path.

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