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

Local Testing Proxy Domain is returning NXDOMAIN (consume.verbb.io) #17

Open
jamesmacwhite opened this issue Dec 16, 2024 · 5 comments
Open

Comments

@jamesmacwhite
Copy link
Contributor

Describe the bug

The domain listed under the Google provider information is returning NXDOMAIN consume.verbb.io

Steps to reproduce

N/A

Craft CMS version

N/A

Plugin version

N/A

Multi-site?

No response

Additional context

No response

@engram-design
Copy link
Member

Looks like a typo, should be proxy.verbb.io.

@jamesmacwhite
Copy link
Contributor Author

Makes sense! As a side note, I guess anyone could implement their own proxy route if needed, given it is just taking the return query param value and forwarding on the request/redirecting?

Not suggesting there is any privacy issues with using the verbb.io endpoint, but in the event of someone want to keep requests within their own domain, could the local proxy URL path be customised to a non verbb domain? The setting at the moment, I think just enables the option to go to verbb.io

@engram-design
Copy link
Member

Yeah, I totally get that, and I agree it should be configurable. I don't really mind where it goes, so long as it redirects back! I'm sure most people can't be bothered implementing this loophole and just want it to work (for local development), but very happy to make it configurable.

My other concern was support. I really don't want to be helping people who have their own proxy setup and things aren't working, which I can forsee happening.

Just need to write up some docs, and add this as a setting. You can start with this example PHP file as a redirect handler.

<?php

// Rip out the return URL
$return = $_GET['return'] ?? null;

if (!$return) {
    exit;
}

unset($_GET['return']);

// Build the query string again
$query = http_build_query($_GET);

// Does the return URL contain two `?` values? Usually this is a sign of `usePathInfo = false` and we have to deal with a string like
// `http://formie.test/index.php?p=actions/formie/integrations/callback?state=f2fd2d5e084b406010035c4308624f23`
$returnUrl = parse_url($return);
$returnUrlQuery = $returnUrl['query'] ?? '';

// Does the query string also include a `?`? If so, replace with `&`
if ($returnUrlQuery && strstr($returnUrlQuery, '?')) {
    $newQuery = str_replace('?', '&', $returnUrlQuery);

    // There's not actually an easy way to un-`parse_url` so modify the string and save back
    $return = str_replace($returnUrlQuery, $newQuery, $return);
}

// Does this contain a query string already? Append to it, or add
if (strstr($return, '?')) {
    header("Location: $return&$query");
} else {
    header("Location: $return?$query");
}

@jamesmacwhite
Copy link
Contributor Author

Thanks for this. I do understand the barrier to entry aspect and not wanting to support random proxy stuff. I'd be inclined to implement it as a Craft Controller, there's a few helpers to perhaps reduce the plain PHP handler side, but both would do the job fine.

For what it is worth, any ddev.site environment is accepted without it, I assume specific scenarios like localhost and .test (possibly Laravel Valet?) get caught in it.

@engram-design
Copy link
Member

For sure, you can use Craft if you like - just seemed a bit too much overhead to route the request through Craft for just a proxy. It's just got to be a public-facing URL that's all.

The ddev.site is an interesting one, and an option we'll suggest. Like that option, you could also use ngrok yourself and manage the proxy that way. Again, just requires some manual work to spin up, and have the connection active/have a paid account.

All options that are up to the user, so long as the proxy is configurable!

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

No branches or pull requests

2 participants