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

Add a configurable base_url for Amundsen front end #424

Closed
dmateusp opened this issue Apr 29, 2020 · 18 comments
Closed

Add a configurable base_url for Amundsen front end #424

dmateusp opened this issue Apr 29, 2020 · 18 comments
Assignees
Labels
area:frontend From the Frontend folder help wanted Extra attention is needed status:needs_votes Issue or bug fix that needs support from the community to be considered type:feature A new feature request

Comments

@dmateusp
Copy link
Contributor

at Earnest we use a single domain with Ambassador and diverse mapping rules to add public endpoints for our Kubernetes-hosted web applications

I'm having an issue with the front end, due to the fact that Amundsen is not at the root of the domain, and I believe I cannot support it currently because the path to static files is hardcoded in the html: example

I think I would need static to be a dynamic path where I could append /amundsen/ (I would actually like the whole web service to serve traffic only on /amundsen/ and not at /)

Airflow uses url_for here for example.

Then I would like the helm chart to allow me to specify the base_url

see how Airflow does it in its helm chart

@feng-tao
Copy link
Member

@ttannis @danwom could you two take a look when you have a chance?

@feng-tao feng-tao added amundsenfrontendlibrary keep fresh Disables stalebot from closing an issue labels Apr 30, 2020
@dmateusp
Copy link
Contributor Author

hey I have work in progress on this, I should have a PR soon

@feng-tao
Copy link
Member

sounds good

@Golodhros
Copy link
Member

Hi @dmateusp, how is this going? Do you need any help?

@Golodhros Golodhros added status:in_progress Issue that is being worked on right now type:feature A new feature request labels May 29, 2020
@dmateusp
Copy link
Contributor Author

hey @Golodhros I thought this would only involve Python changes, but there's some JavaScript which I'm unsure how to modify the "right way" to support this feature

There's a Draft PR here amundsen-io/amundsenfrontendlibrary#435

sorry I didn't report back on status, I'm happy to continue it if someone with JS / Front-end experience can let me know if the way I'm going is ok, happy to drop it as well if someone else would like to implement it

@Golodhros
Copy link
Member

Hi @dmateusp, thanks for the prompt response!

The template file has changed lately, and now we use the HtmlWebpackPlugin to insert the file paths of our assets instead of hardcoding them on the template. I think we would be able to modify the "publicPath" property to change the path. Could you give it a try?

Also, would love to hear more about the change from "axios" to "axiosInstance" in your PR. Was something not working properly?

Thanks a lot for your contribution to the project!

@janbe-ts
Copy link

Hi all,

we would also like to run Amundsen behind a reverse proxy and are therefore dependent on a configurable base_url. Are there any updates on this? Or does anyone know about a workaround for this issue? Guess it's not that easy, but is there a chance to configure the react app like described here https://create-react-app.dev/docs/deployment/#serving-the-same-build-from-different-paths?

@ttannis
Copy link
Contributor

ttannis commented Sep 29, 2020

Hi all,

we would also like to run Amundsen behind a reverse proxy and are therefore dependent on a configurable base_url. Are there any updates on this? Or does anyone know about a workaround for this issue? Guess it's not that easy, but is there a chance to configure the react app like described here https://create-react-app.dev/docs/deployment/#serving-the-same-build-from-different-paths?

No updates as this item isn't something explicitly on the roadmap, so for now it is a matter of someone looking into it and submitting a PR. In our community slack channel you can talk to others who are interested in this feature, and perhaps with multiple folks looking into this it can get moved along. There have already been some attempts linked above, so a starting point could be to understand how far others got and what did or didn't work.

@janbe-ts
Copy link

janbe-ts commented Oct 1, 2020

Thanks @ttannis for the quick response. I've joined the Slack channel and will see what I can do

@richwhitjr
Copy link

We are having the same issue trying Amundsen internally. Also using ambassador with the helm chat provided.

@mymzheka
Copy link

Having the same issue, need help. Any workaround?

@ajitkshirsagar
Copy link

Having the same issue. Any path forward?
Has anyone tried hosting on Kubernetes or compute machine?

@guillemborrell
Copy link

This is also affecting our deployment, since we are using the helm chart and we have to keep a separate domain for Amundsen. Not sure if I can help, but this feature would have a very positive impact in our deployment.

@janbe-ts
Copy link

janbe-ts commented Jan 29, 2021

We managed to run the Amundsen frontend behind a base URL by maintaining a local fork and a few code changes. Unfortunately, it's a hacky solution because the base URL needs to be hardcoded. Here's what we did

  • Add a baseURL field to AppConfigCustom in amundsen_application/static/js/config like this
[...]
logoPath: 'my/path/to/logo',
navLinks: [],
baseURL: '/<my-base-url>',
  • In the index.ts, add this line to the top axios.defaults.baseURL = AppConfig.baseURL; All API calls will now automatically have the baseURL prefixed
  • Some assets unfortunately have a hardcoded URL, so we also need to add the baseURL there, e.g. src={AppConfig.baseURL + '/static/images/loading_spinner.gif'} in LoadingSpinner/index.tsx
  • In the amundsen_application base folder, I added a file middleware.py
from collections import Callable

from werkzeug.wsgi import ClosingIterator


class PrefixMiddleware:

    def __init__(self, app: Callable, prefix: str = ''):
        self.app = app
        self.prefix = prefix

    def __call__(self, environ: dict, start_response: Callable) -> ClosingIterator:
        if environ['PATH_INFO'].startswith(self.prefix):
            environ['PATH_INFO'] = environ['PATH_INFO'][len(self.prefix):]
            environ['SCRIPT_NAME'] = self.prefix
            return self.app(environ, start_response)

        return self.app(environ, start_response)
  • Finally, in wsgi.py, we change the main function to use the new middleware:
if __name__ == '__main__':
    application.wsgi_app = PrefixMiddleware(application.wsgi_app, prefix=os.getenv('BASE_URL'))
    application.run(host='0.0.0.0')

If there is a way to pass an environment variable to the react component, this would actually be a generic solution and the baseURL could be configured in the helm charts. Maybe someone has an idea how to do that?

Hope this helps somebody!

@guillemborrell
Copy link

@janbe-ts This is brilliant! Thanks.

I agree that this requires very little changes upstream to be a permanent solution.

@seongk
Copy link

seongk commented Feb 5, 2021

Adding a comment here to say I'm having the same issue. I'll try out @janbe-ts solution above and report back. Thanks!
Hope there's a permanent solution soon.

@verdan verdan pinned this issue Feb 24, 2021
dorianj pushed a commit to dorianj/amundsen that referenced this issue Apr 25, 2021
* Initial commit for Dashboards feature (amundsen-io#394)

* Initial Dashboard commit
- Added a DashboardPage and route
- Added basic getDashboard reducer/saga/API
- Added basic tests for dashboard page
- Cleaned up tabs component styles

* Add chart and query component to dashboard page (amundsen-io#403)

* Fix rebase syntax error in _layouts.scss

* Initial dashboard search (amundsen-io#411)

* Dummy python code

* Python updates; React App support

* Some code cleanup

* Python tests

* Add some tests

* Lint/test fix

* Update ProfilePage & My Bookmarks to new design (amundsen-io#416)

* Dummy python code

* Python updates; React App support

* Some code cleanup

* Python tests

* Add some tests

* Lint/test fix

* Update ProfilePage & My Bookmarks to new design

* Add some tests

* Update Dashboard Search UI (amundsen-io#424)

* Update UI

* Cleanup; Add some tests; Update doc

* Lint fix

* Update search payload used

* Lint fix; Test fix;

* Some last tests

* Add Dashboard Preview UI Support (amundsen-io#425)

* WIP

* Default loading error message; Resolve titleNode vs title

* Cleanup ducks

* Component tests

* Ducks tests

* Log exception omn file not found error

* Dashboard Bookmarks & Dashboard ProfilePage support (amundsen-io#427)

* Initial implementation

* Some tests; Some cleanup; Add owners

* Code cleanup; Tests

* Connect dashboard page with API (amundsen-io#426)

* Connected the dashboard get API
- Added several metadata fields
- Added dashboard Tables
* Added dashboard tag api
* Refactor tags to support multiple resource types
* Fixed tag refresh logic
* Removed tag extraction helper methods

* Update dashboard preview UI (amundsen-io#430)

* Update endpoint logic; Update ImagePreview

* Remove preview redux logic

* Tests

* Some code cleanup

* Add dashboard url to preview error message

* Switch order of People & Dashboards across search UI (amundsen-io#431)

* Dashboard Page Updates (amundsen-io#432)

* Update last run state ui; Update badge colors

* Add support for 'No owner' UI

* Add icon to DashboardPage; Add update description UI

* Update description UI according to direction from Design

* Code cleanup based on review comments

* List Item UI Updates (amundsen-io#433)

* Update last run state ui; Update badge colors

* Add support for 'No owner' UI

* Add icon to DashboardPage; Add update description UI

* Update description UI according to direction from Design

* Code cleanup based on review comments

* Update dashboard group css

* Center list items; Update queryitem height; Add chartitem keys

* TabsComponent border always under tabs

* Do not render ChartList if no charts

* Center UserListItem

* Add count to dashboard right panel tabs (amundsen-io#438)

* Cleanup: Delete unused code

* Cleanup: Remove unsued import

* Dashboard Logging Updates (amundsen-io#436)

* Support logging dashboard source & index; Consolidate logic into utility

* log interaction with description edit

* Update method name for a less ambiguous command name in logs

* Revert add description logging -- there is a new design

* Cleanup

* Improve coverage under DashboardPage

* Update ImagePreview; Fix imports

* Add a dashboardsummary fixture; Fix indentation

* ducks/dashboard tests

* Update application_config doc

* Added a 'beta' flag for dashboards (amundsen-io#441)

* Added a 'beta' flag for dashboards

* Reorder imports

* Remove config for hard coding beta tags

* Cleanup

* Dashboard -> DashboardMetadata

* Remove obsolete TODO; Use DashboardSummary schema

* Remove other TODO

* Fix python tests & lint

Co-authored-by: Daniel <dwon@lyft.com>
dorianj pushed a commit to dorianj/amundsen that referenced this issue Apr 25, 2021
feng-tao pushed a commit that referenced this issue May 7, 2021
* Initial commit for Dashboards feature (#394)

* Initial Dashboard commit
- Added a DashboardPage and route
- Added basic getDashboard reducer/saga/API
- Added basic tests for dashboard page
- Cleaned up tabs component styles

* Add chart and query component to dashboard page (#403)

* Fix rebase syntax error in _layouts.scss

* Initial dashboard search (#411)

* Dummy python code

* Python updates; React App support

* Some code cleanup

* Python tests

* Add some tests

* Lint/test fix

* Update ProfilePage & My Bookmarks to new design (#416)

* Dummy python code

* Python updates; React App support

* Some code cleanup

* Python tests

* Add some tests

* Lint/test fix

* Update ProfilePage & My Bookmarks to new design

* Add some tests

* Update Dashboard Search UI (#424)

* Update UI

* Cleanup; Add some tests; Update doc

* Lint fix

* Update search payload used

* Lint fix; Test fix;

* Some last tests

* Add Dashboard Preview UI Support (#425)

* WIP

* Default loading error message; Resolve titleNode vs title

* Cleanup ducks

* Component tests

* Ducks tests

* Log exception omn file not found error

* Dashboard Bookmarks & Dashboard ProfilePage support (#427)

* Initial implementation

* Some tests; Some cleanup; Add owners

* Code cleanup; Tests

* Connect dashboard page with API (#426)

* Connected the dashboard get API
- Added several metadata fields
- Added dashboard Tables
* Added dashboard tag api
* Refactor tags to support multiple resource types
* Fixed tag refresh logic
* Removed tag extraction helper methods

* Update dashboard preview UI (#430)

* Update endpoint logic; Update ImagePreview

* Remove preview redux logic

* Tests

* Some code cleanup

* Add dashboard url to preview error message

* Switch order of People & Dashboards across search UI (#431)

* Dashboard Page Updates (#432)

* Update last run state ui; Update badge colors

* Add support for 'No owner' UI

* Add icon to DashboardPage; Add update description UI

* Update description UI according to direction from Design

* Code cleanup based on review comments

* List Item UI Updates (#433)

* Update last run state ui; Update badge colors

* Add support for 'No owner' UI

* Add icon to DashboardPage; Add update description UI

* Update description UI according to direction from Design

* Code cleanup based on review comments

* Update dashboard group css

* Center list items; Update queryitem height; Add chartitem keys

* TabsComponent border always under tabs

* Do not render ChartList if no charts

* Center UserListItem

* Add count to dashboard right panel tabs (#438)

* Cleanup: Delete unused code

* Cleanup: Remove unsued import

* Dashboard Logging Updates (#436)

* Support logging dashboard source & index; Consolidate logic into utility

* log interaction with description edit

* Update method name for a less ambiguous command name in logs

* Revert add description logging -- there is a new design

* Cleanup

* Improve coverage under DashboardPage

* Update ImagePreview; Fix imports

* Add a dashboardsummary fixture; Fix indentation

* ducks/dashboard tests

* Update application_config doc

* Added a 'beta' flag for dashboards (#441)

* Added a 'beta' flag for dashboards

* Reorder imports

* Remove config for hard coding beta tags

* Cleanup

* Dashboard -> DashboardMetadata

* Remove obsolete TODO; Use DashboardSummary schema

* Remove other TODO

* Fix python tests & lint

Co-authored-by: Daniel <dwon@lyft.com>
feng-tao pushed a commit that referenced this issue May 7, 2021
@karthikmadupu
Copy link

@janbe-ts @guillemborrell @seongk Guys am trying workaround suggested by janbe but till doesn't work.
Can anyone guide me. Am modifying below files(mentioning relative paths of file)

frontend/amundsen_application/static/js/config/config-default.ts
frontend/amundsen_application/static/js/config/config-types.ts
frontend/amundsen_application/static/js/components/LoadingSpinner/index.tsx
frontend/amundsen_application/static/js/index.tsx
frontend/amundsen_application/middleware.py
frontend/amundsen_application/wsgi.py

@janbe-ts
Copy link

@karthikmadupu can you provide a bit more context? What exactly does not work, what have you tried, what error message(s) do you get?

hansadriaans pushed a commit to DataChefHQ/amundsen that referenced this issue Jun 30, 2022
hansadriaans pushed a commit to DataChefHQ/amundsen that referenced this issue Jun 30, 2022
* Initial commit for Dashboards feature (amundsen-io#394)

* Initial Dashboard commit
- Added a DashboardPage and route
- Added basic getDashboard reducer/saga/API
- Added basic tests for dashboard page
- Cleaned up tabs component styles

* Add chart and query component to dashboard page (amundsen-io#403)

* Fix rebase syntax error in _layouts.scss

* Initial dashboard search (amundsen-io#411)

* Dummy python code

* Python updates; React App support

* Some code cleanup

* Python tests

* Add some tests

* Lint/test fix

* Update ProfilePage & My Bookmarks to new design (amundsen-io#416)

* Dummy python code

* Python updates; React App support

* Some code cleanup

* Python tests

* Add some tests

* Lint/test fix

* Update ProfilePage & My Bookmarks to new design

* Add some tests

* Update Dashboard Search UI (amundsen-io#424)

* Update UI

* Cleanup; Add some tests; Update doc

* Lint fix

* Update search payload used

* Lint fix; Test fix;

* Some last tests

* Add Dashboard Preview UI Support (amundsen-io#425)

* WIP

* Default loading error message; Resolve titleNode vs title

* Cleanup ducks

* Component tests

* Ducks tests

* Log exception omn file not found error

* Dashboard Bookmarks & Dashboard ProfilePage support (amundsen-io#427)

* Initial implementation

* Some tests; Some cleanup; Add owners

* Code cleanup; Tests

* Connect dashboard page with API (amundsen-io#426)

* Connected the dashboard get API
- Added several metadata fields
- Added dashboard Tables
* Added dashboard tag api
* Refactor tags to support multiple resource types
* Fixed tag refresh logic
* Removed tag extraction helper methods

* Update dashboard preview UI (amundsen-io#430)

* Update endpoint logic; Update ImagePreview

* Remove preview redux logic

* Tests

* Some code cleanup

* Add dashboard url to preview error message

* Switch order of People & Dashboards across search UI (amundsen-io#431)

* Dashboard Page Updates (amundsen-io#432)

* Update last run state ui; Update badge colors

* Add support for 'No owner' UI

* Add icon to DashboardPage; Add update description UI

* Update description UI according to direction from Design

* Code cleanup based on review comments

* List Item UI Updates (amundsen-io#433)

* Update last run state ui; Update badge colors

* Add support for 'No owner' UI

* Add icon to DashboardPage; Add update description UI

* Update description UI according to direction from Design

* Code cleanup based on review comments

* Update dashboard group css

* Center list items; Update queryitem height; Add chartitem keys

* TabsComponent border always under tabs

* Do not render ChartList if no charts

* Center UserListItem

* Add count to dashboard right panel tabs (amundsen-io#438)

* Cleanup: Delete unused code

* Cleanup: Remove unsued import

* Dashboard Logging Updates (amundsen-io#436)

* Support logging dashboard source & index; Consolidate logic into utility

* log interaction with description edit

* Update method name for a less ambiguous command name in logs

* Revert add description logging -- there is a new design

* Cleanup

* Improve coverage under DashboardPage

* Update ImagePreview; Fix imports

* Add a dashboardsummary fixture; Fix indentation

* ducks/dashboard tests

* Update application_config doc

* Added a 'beta' flag for dashboards (amundsen-io#441)

* Added a 'beta' flag for dashboards

* Reorder imports

* Remove config for hard coding beta tags

* Cleanup

* Dashboard -> DashboardMetadata

* Remove obsolete TODO; Use DashboardSummary schema

* Remove other TODO

* Fix python tests & lint

Co-authored-by: Daniel <dwon@lyft.com>
@Golodhros Golodhros added status:needs_votes Issue or bug fix that needs support from the community to be considered help wanted Extra attention is needed area:frontend From the Frontend folder and removed status:in_progress Issue that is being worked on right now Project: Frontend labels Dec 8, 2022
@Golodhros Golodhros removed the keep fresh Disables stalebot from closing an issue label Dec 15, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area:frontend From the Frontend folder help wanted Extra attention is needed status:needs_votes Issue or bug fix that needs support from the community to be considered type:feature A new feature request
Projects
None yet
Development

No branches or pull requests