Skip to content
This repository has been archived by the owner on Jan 12, 2023. It is now read-only.

Proxy backend APIs #214

Merged
merged 6 commits into from Nov 13, 2020
Merged

Proxy backend APIs #214

merged 6 commits into from Nov 13, 2020

Conversation

gildub
Copy link
Contributor

@gildub gildub commented Nov 13, 2020

Resolves #152

@gildub gildub requested a review from a team November 13, 2020 10:58
@konveyor-preview-bot
Copy link

🚀 Deployed Preview: http://konveyor-virt-ui-pr-214-preview.surge.sh

@gildub gildub changed the title Proxy backend APIs [WIP] Proxy backend APIs Nov 13, 2020
Copy link
Collaborator

@mturley mturley left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@gildub aside from the comments below, the only thing you were missing was to change the UI code so it uses those new /cluster-api, /inventory-api and /inventory-payload-api URLs instead of the ones in VIRT_META!

I made this change locally and the proxy works flawlessly!

I opened a PR against your branch to make this change: https://github.com/gildub/virt-ui/pull/1

deploy/server.js Outdated
@@ -69,7 +71,59 @@ if (process.env['DATA_SOURCE'] !== 'mock') {
});
}

app.get('*', (req, res) => {
let clusterApiProxyOptions = {
target: virtMeta.clusterApi,
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

For these targets, we should have conditions where in prod we use the internal endpoints described in #152 (comment) instead of the values from virtMeta.

e.g.

let clusterApiProxyOptions = {
  target:
    process.env['NODE_ENV'] !== 'development'
      ? 'https://api.openshift-apiserver.svc.cluster.local/'
      : virtMeta.clusterApi,
  [...]
};

};

if (process.env['NODE_ENV'] === 'development') {
clusterApiProxyOptions = {
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Or I suppose you could just replace the target properties here since you already have a condition for dev mode.

@mturley
Copy link
Collaborator

mturley commented Nov 13, 2020

To save time I'll go ahead and address the other feedback in https://github.com/gildub/virt-ui/pull/1.

@mturley
Copy link
Collaborator

mturley commented Nov 13, 2020

Ok, https://github.com/gildub/virt-ui/pull/1 is ready and addresses all of the above.

@mturley
Copy link
Collaborator

mturley commented Nov 13, 2020

We should probably also remove the CertErrorPage and all the logic for redirecting to it. That can be a follow-up PR though.

@gildub
Copy link
Contributor Author

gildub commented Nov 13, 2020

@mturley, great, thanks.

@gildub gildub changed the title [WIP] Proxy backend APIs Proxy backend APIs Nov 13, 2020
Switch UI to use proxied API paths, switch proxy to use internal `.local` URLs, disable HTTPS
@gildub gildub requested a review from mturley November 13, 2020 21:53
@mturley
Copy link
Collaborator

mturley commented Nov 13, 2020

Whoops! Thanks for the fix.

Copy link
Collaborator

@mturley mturley left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM!

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Look into proxying inventory and host cluster APIs through Express to avoid SSL/CORS errors
3 participants