GithubHelp home page GithubHelp logo

Comments (11)

AlexV525 avatar AlexV525 commented on May 23, 2024

You should write https://example.com/api/ for baseUrl.

from dio.

mitryp avatar mitryp commented on May 23, 2024

You should write https://example.com/api/ for baseUrl.

The frontend does not necessarily know the full path.
It's not clear to me, why using a relative path isn't allowed.

from dio.

AlexV525 avatar AlexV525 commented on May 23, 2024

How do the instance be able to make requests if the full path is unavailable?

from dio.

mitryp avatar mitryp commented on May 23, 2024

Web applications can request the same origin using relative paths.
Take a look at a W3Schools reference
They also suggest to use relative paths when possible

from dio.

AlexV525 avatar AlexV525 commented on May 23, 2024

Dio won't know your origin unless you define so. It's not a Web application.

Closing as intended and won't fix.

from dio.

kuhnroyal avatar kuhnroyal commented on May 23, 2024

Not so sure, this may actually be a valid request for Flutter Web platform.

from dio.

mitryp avatar mitryp commented on May 23, 2024

The problem is not that Dio doesn't know something, but it just stops users from using relative paths with an assert.

You cannot as that it is not a web app, because Dio can indeed be used as a client in a web application.

As for me, it's quite strange to forbid the usage of something that is a part of the specification for no reason, especially when the actual request functionality works and the problem is in an unnecessary assert statement.

Or is there a reason why it is forbidden?

from dio.

AlexV525 avatar AlexV525 commented on May 23, 2024

Not so sure, this may actually be a valid request for Flutter Web platform.

It could be possible to resolve by Uri.base.resolve(path) specifically on Web.
https://api.flutter.dev/flutter/dart-core/Uri/base.html

However, it's also available when you're setting the baseUrl.

from dio.

mitryp avatar mitryp commented on May 23, 2024

Yes, if you look at the initial issue, it is possible to bypass the assert using the setter for baseUrl after the BaseOptions is created.

But if it's so, why the asset is there in the first place?

from dio.

AlexV525 avatar AlexV525 commented on May 23, 2024

You cannot as that it is not a web app, because Dio can indeed be used as a client in a web application.

I have the opposite opinion here. Dio is not in any form, an application. As you declared, it can only be used in a Web application.

As for me, it's quite strange to forbid the usage of something that is a part of the specification for no reason, especially when the actual request functionality works and the problem is in an unnecessary assert statement.

Could you provide a reproducible example that it can run without the assertion?

But if it's so, why the asset is there in the first place?

You can use the blame view to determine when it's been introduced to find out the cause.

from dio.

mitryp avatar mitryp commented on May 23, 2024

Could you provide a reproducible example that it can run without the assertion?

I created a repo with the minimal reproducible example of both the exception and the supposed behaviour. Its README describes the steps to reproduce both situations.

You can use the blame view to determine when it's been introduced to find out the cause.

diox/#18 has an issue of #1373 connected, but it's still unclear why baseUrl must include the host in the first place.

from dio.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.