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

fix: check if api is reachable during registration #56

Merged

Conversation

MoritzKrafeld
Copy link
Member

Fixes #55
During registration, we check if the API is reachable instead of just the APP_URL because this could also be mapped to a sales channel which is currently in maintenance mode.

@@ -33,7 +33,7 @@ public function __invoke(BeforeRegistrationStartsEvent $event): void
$shop = $event->getShop();

try {
$this->httpClient->request('HEAD', $shop->getShopUrl(), [
$this->httpClient->request('HEAD', sprintf("%s/api/_info/config", $shop->getShopUrl()), [
Copy link
Member

Choose a reason for hiding this comment

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

the problem with that is that we get always a 401 🤔. is that fine. @nsaliu

Copy link
Member Author

Choose a reason for hiding this comment

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

Not in this case when we do a HEAD instead of POST request 😄

Copy link
Member Author

Choose a reason for hiding this comment

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

Sorry, POST is not allowed but even a GET would return a HTTP 200 with the 401 error in the payload 🙈
But a HEAD does also return a 200 without any response body and also no error 😄

Copy link
Contributor

Choose a reason for hiding this comment

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

Nice catch!

Copy link
Member Author

Choose a reason for hiding this comment

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

Thanks to our awesome community! 😄

Copy link
Contributor

Choose a reason for hiding this comment

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

@MoritzKrafeld

But a HEAD does also return a 200 without any response body and also no error

Are you sure about that 🤔
When I try e.g. curl --head http://localhost:8000/api/_info/config, i am always getting 401 😬

How did you tried that?

Copy link
Member Author

Choose a reason for hiding this comment

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

Hmm you're right. I'm also getting 401 as a response. I tried this is a few APP_URL's of our customers and never had the problem with that and always got the 200 back 🙈
I will create a PR so that we also allow 401 (or something which would indicate us that the server is reachable) 😅

Copy link
Member Author

Choose a reason for hiding this comment

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

Should hopefully be fixed in this PR: #58

@MoritzKrafeld MoritzKrafeld requested a review from shyim January 15, 2025 12:33
@MoritzKrafeld MoritzKrafeld merged commit d26bd4c into main Jan 15, 2025
9 checks passed
@mitelg mitelg deleted the fix-55/check-shop-url-is-reachable-in-maintenance-mode branch January 15, 2025 13:04
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.

check_if_shop_url_is_reachable fails when shop is in maintenance mode
5 participants