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

Dart client should accept/prefer "local" as subdomain for local-cli development now that localhost is deprecated #107

Closed
spakanati opened this issue Jul 25, 2023 · 8 comments
Labels
Investigate Working to figure out what's wrong!

Comments

@spakanati
Copy link
Contributor

Currently you have to pass "localhost" or "localhost:1337" as the subdomain for local cli dev:
https://github.com/nhost/nhost-dart/blob/main/packages/nhost_dart/lib/nhost_dart.dart#L50

However, Nhost has deprecated localhost as the subdomain and it seems "local" should be used instead.

@mhadaily
Copy link
Contributor

mhadaily commented Aug 7, 2023

Unfortunately, if that is the case (pleases share the doc thank you :D ) it's not yet supported, and you still need to pass localhost.

I will see if I can spend sometime to fix this.

@mhadaily mhadaily added the Investigate Working to figure out what's wrong! label Aug 7, 2023
@spakanati
Copy link
Contributor Author

spakanati commented Aug 7, 2023

Thanks! Unfortunately it's not as simple as just passing localhost because the new nhost cli does not even run services on localhost:1337 anymore as far as I know (so local development is broken without any workarounds until this is updated). I believe the specific URLs (local.auth.nhost.run, etc.) need to be used.

I don't have a specific link to the docs but the deprecation of localhost has been discussed on Discord and there is an issue here to remove all references to localhost: nhost/nhost#2139

@mhadaily
Copy link
Contributor

mhadaily commented Aug 7, 2023

How about using serviceUrls directly for local development?

      serviceUrls: ServiceUrls(
        authUrl: '',
        storageUrl: '',
        functionsUrl: '',
        graphqlUrl: '',
      ),
    );``` 

@spakanati
Copy link
Contributor Author

I tried using the service URLs as a workaround, but it doesn't work because nhost gql links can't connect to the websocket successfully: WebSocketException (WebSocketException: Connection to 'https://local.graphql.nhost.run:0#' was not upgraded to websocket)

Possibly wss is not supported locally, but the URL is https://local.graphql.nhost.run:

Screenshot 2023-08-07 at 5 30 21 PM

@vipafattal
Copy link

Any updates, I need to test locally and it's seems there is no way to do that

@dbarrosop
Copy link
Member

what is the issue? Could someone elaborate a bit more and share logs and errors? I just tested myself and I had no problems using subscriptions using both local.graphql.nhost.run/v1 and local.hasura.nhost.run/v1/graphql

@spakanati
Copy link
Contributor Author

The issue is that Nhost has asked everyone to switch to using subdomain and region to initiate the client and also to stop using "localhost" for local development and instead pass "local" as the subdomain. The dart client is still assuming that "localhost' will be passed as the subdomain that local development is using localhost:1337, which has not been the case for a while with the newer version of cli, so all the examples will fail if you use "local" as the subdomain because the endpoints created are incorrect, and just passing the legacy "localhost" for subdomain as a workaround does not work either since cli services are not actually running at localhost:1337 anymore.

See this incorrect regexp that has not been updated.

It is now possible to use the service URLs workaround and pass each service URL individually to initiate the client, but it should not be necessary because the init code should be fixed to handle subdomain and region correctly in all cases, including local development.

@dbarrosop
Copy link
Member

Solved in #119

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Investigate Working to figure out what's wrong!
Projects
None yet
Development

No branches or pull requests

4 participants