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

chore(devserver): set server authority to localhost #364

Merged
merged 1 commit into from
Jan 27, 2022

Conversation

andrewazores
Copy link
Member

@andrewazores andrewazores commented Jan 27, 2022

Fixes #363

Noticed this one while looking into https://github.com/cryostatio/cryostat/issues/802 . When running the backend with a typical CRYOSTAT_CORS_ORIGIN=http://localhost:9000 CRYOSTAT_DISABLE_SSL=true CRYOSTAT_DISABLE_JMX_AUTH=true sh smoketest.sh, JWT token download requests fail because the URL of the requested resource was still using http://0.0.0.0:8181, but the server is listening on and expecting requests to use http://localhost:8181 in this setup. To test, just try to download an event template using a devserver web client. Without this change it fails with an error about the request resourceUrl being invalid. With this change it should succeed.

This can also be worked around by setting the CRYOSTAT_WEB_HOST env var when starting the backend - setting it back to the old 0.0.0.0 to override the default localhost read out of the pom.xml sets it back to how it used to work, when .env was created.

@andrewazores andrewazores added the chore Refactor, rename, cleanup, etc. label Jan 27, 2022
@andrewazores andrewazores requested a review from jan-law January 27, 2022 16:40
Copy link
Contributor

@jan-law jan-law left a comment

Choose a reason for hiding this comment

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

I noticed the same thing about the CRYOSTAT_AUTHORITY yesterday, except when I changed CRYOSTAT_AUTHORITY to use localhost, the successfully downloaded template is always named TARGET for me. Is it the same for you?

@andrewazores
Copy link
Member Author

Yes, that's just an unfortunate effect of using a CORS setup. When the client origin and the server origin differ, the browser ignores the client's hint as to what to name any downloaded file, and will insist on naming it whatever the last portion of the request URL was. I suppose this is to help users notice if some malicious client is masquerading as the frontend for some other service that the user thinks they're actually using.

Copy link
Contributor

@jan-law jan-law left a comment

Choose a reason for hiding this comment

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

the browser ignores the client's hint as to what to name any downloaded file, and will insist on naming it whatever the last portion of the request URL was

Ah, I see, that's unfortunate, but not a big deal.

Can this PR also close https://github.com/cryostatio/cryostat/issues/802 then? The backend doesn't need any changes as far as I can tell.

@andrewazores
Copy link
Member Author

Oh - does this also fix the https://github.com/cryostatio/cryostat/issues/802 issue? I didn't think that it did. I was able to reproduce that one just running smoketest.sh without the CORS devserver setup.

@jan-law
Copy link
Contributor

jan-law commented Jan 27, 2022

My bad, https://github.com/cryostatio/cryostat/issues/802 is still an issue without the CORS devserver setup. With this PR though, the templates can download if you use CRYOSTAT_CORS_ORIGIN=http://localhost:9000.

@andrewazores andrewazores merged commit 16410a7 into cryostatio:main Jan 27, 2022
@andrewazores andrewazores deleted the devserver-env-host branch January 27, 2022 18:25
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
chore Refactor, rename, cleanup, etc.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

devserver env uses 0.0.0.0 authority instead of localhost
2 participants