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

scope plugins to support adjusting app base path #7

Merged
merged 1 commit into from
Mar 2, 2023

Conversation

digitalsadhu
Copy link
Member

This PR makes it possible to set an app.base config value and have the whole app mounted in the server correctly based on this value. If the value is not set, the app uses the app.name as the pathname instead.

Behaviour is as follows:

  • no app.base set, app base pathname set to /<app.name>
  • app.base set, app base pathname set to /<app.base> n.b. app.base can be set to / to have the app mounted at the root.
  • all routes are mounted under the pathname, this goes for manifest, content, fallback and any additional api routes and locally served static assets

Assets

There is an assets.base value which has some interaction with app.base. assets.base behaviour is as follows

  • defaults to /static locally which is where the dist folder is served.
  • If assets.base is set to an absolute url then local assets will not be served and assets will be loaded from this absolute url.
  • If assets.base is not an absolute value, it will be concatenated with the app pathname (as above, either from app.base or app.name)

Examples:

// config/common.json
{
  "app": {
    "base": "/foo"
  },
  "assets": {
    "base": "/bar"
  }
}

// app served at http://localhost:8080/foo
// app assets served at http://localhost:8080/foo/bar
// config/common.json
{
  "app": {
    "base": "/foo"
  }
}

// app served at http://localhost:8080/foo
// app assets served at http://localhost:8080/foo/static
// config/common.json
{
  "app": {
    "base": "/foo"
  },
  "assets": {
    "base": "https://assets.foo.com/static"
  }
}

// app served at http://localhost:8080/foo
// app assets served at https://assets.foo.com/static
// package.json
{
  "name": "foo"
}

// config/common.json
{}

// app served at http://localhost:8080/foo
// app assets served at http://localhost:8080/foo/static
// package.json
{
  "name": "foo"
}

// config/common.json
{
  "assets": {
    "base": "/bar"
  }
}

// app served at http://localhost:8080/foo
// app assets served at http://localhost:8080/foo/bar

@digitalsadhu digitalsadhu merged commit 31db26d into main Mar 2, 2023
@digitalsadhu digitalsadhu deleted the scope_plugins branch March 2, 2023 09:13
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

Successfully merging this pull request may close these issues.

1 participant