question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Don't know how to change base URL

See original GitHub issue

I want to serve all platformatic content with a prefix of /v1 (for instance) so I can set up routing properly. Right now each table is served in the root directory, e.g. table users is in /users; not good for routing.

I have tried to set up a base path of /v1 in several ways but no luck.

  • I tried to set basePath in Swagger config.
  • I have also tried to set up an openapi object inside core, with an attribute: "servers": [{"url": "/v1"}]. In this case I get an error: “Failed to load API definition”. Full configuration below.
  • I don’t see any config parameters in Platformatic itself to set up the basePath (or baseUrl).

What am I missing? Thanks in advance!

Full platformatic.db.json:

{
    "server": {
        "hostname": "0.0.0.0",
        "port": "3042",
        "cors": {
            "origin": "{PLT_SERVER_CORS_ORIGIN}"
        }
    },
    "core": {
        "connectionString": "{PLT_DATABASE_CONNECTION_URL}",
        "graphql": false,
        "openapi": {
            "servers": [{
                "url": "/v1"
            }]
        }
    },
    "migrations": {
        "dir": "./migrations"
    }
}

Note: setting "openapi": {} works but again everything is served from the base path /.

Issue Analytics

  • State:closed
  • Created a year ago
  • Comments:6 (4 by maintainers)

github_iconTop GitHub Comments

1reaction
mcollinacommented, Oct 9, 2022

We should add a prefix in the config but not inside server, the prefix should be limited to the openapi routes.

1reaction
mcollinacommented, Oct 6, 2022

I recommend we add a prefix option somewhere for all the OpenAPI routes - this issue is not really about the OpenAPI definition but on the route definition.

Read more comments on GitHub >

github_iconTop Results From Across the Web

How can I change the existing base URL of Artifactory - JFrog
Navigate to Admin -> Configuration-> General Configuration-> General settings -> change Custom Base URL to a new url.
Read more >
Change the default base url for axios - Stack Overflow
Change the default base url for axios · 2. you can change the base url of an axios instance by setting: this.$axios. ·...
Read more >
How do I change the Base URL in Drupal 7?
To update - I've changed the url using base url and RewriteCond etc in htaccess and settings.php. It has broken all of the...
Read more >
how to change base url - Atlassian Community
On Cloud you don't change the base url. You register an instance with a name and that's the name. If you are on...
Read more >
Drupal configuration on non root url (how to change $base_url)?
1 Answer 1 · Find the line that reads # RewriteBase /drupal · Uncomment it by deleting the "#" RewriteBase /drupal · Edit...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found