Comments (11)
You should write https://example.com/api/
for baseUrl
.
from dio.
You should write
https://example.com/api/
forbaseUrl
.
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.
How do the instance be able to make requests if the full path is unavailable?
from dio.
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.
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.
Not so sure, this may actually be a valid request for Flutter Web platform.
from dio.
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.
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.
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.
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.
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)
- When an error occurs, an exception is raised on a newer version of Flutter. HOT 1
- The connection errored: Connection failed This indicates an error which most likely cannot be solved by the library. HOT 3
- Access response data type <T> in Interceptor. HOT 5
- SOCKS5 PROXY SUPPORT HOT 1
- Dio on Windows : Invalid media type: expected no more input. HOT 3
- I cannot set a content-type of a form-data field HOT 5
- DioException (DioException [bad response]: This exception was thrown because the response has a status code of 401 and RequestOptions.validateStatus was configured to throw for this status code. HOT 2
- The connection errored: Connection refused This indicates an error which most likely cannot be solved by the library. HOT 1
- [Web] ERROR_TYPE: DioExceptionType.connectionError HOT 2
- Flutter web deployment HOT 1
- [Dio native adapter] proxy HOT 2
- Exception has occurred. DioException (DioException [bad response]: This exception was thrown because the response has a status code of 401 and RequestOptions.validateStatus was configured to throw for this status code. The status code of 401 has the following meaning: "Client error - the request contains bad syntax or cannot be fulfilled" Read more about status codes at https://developer.mozilla.org/en-US/docs/Web/HTTP/Status In order to resolve this exception you typically have either to verify and fix your request code or you have to fix the server code. ) HOT 1
- error 404 when trying to download a file. HOT 3
- How to mock Dio.interceptors.add when write unit test? HOT 1
- Need a way to catch DioException [request cancelled] from the caller code HOT 3
- 有没有大佬帮我看看我的代码有什么问题,handler.resolve(res) 后,原始请求返回值一直为空,不知道为什么? HOT 1
- I don't know where the problem is with my code. After handler.reslove(res), the return value of the original request is always empty. HOT 3
- [Flutter Web] dio.get() sends options. HOT 1
- How to use handler.reject in onError of QueuedInterceptor HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
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.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from dio.