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

Is it impossible to use axios to make network requests in wails dev? #4048

Open
wwwAngHua opened this issue Feb 6, 2025 · 0 comments
Open
Labels
Bug Something isn't working

Comments

@wwwAngHua
Copy link

Description

The problem is this, I use waits to build an application, but I want it to be compatible with the Web as well as macOS, Windows, Linux and other platforms. So, when I use network requests, I use the vite.config.ts configuration to proxy the server API to the local /api directory and solve the CORS problem. When I use npm run dev to debug, there is no problem because it is just an ordinary Web application. However, when I use waits dev to run, I find that when requesting the server API in the /api directory, it does not take effect.

How can I solve this problem? I can't replace all network request methods with Go methods, right?

To Reproduce

In the developer tools, prompts appear when axios makes a network request /api

Failed to load resource: the server responded with a status of 405 (Method Not Allowed) wails://wails.localhost:34115/api/?s=Seg.Auth.Login&username=test1&password=test1
Unhandled Promise Rejection: AxiosError: Request failed with status code 405

Expected behaviour

I want it to run on both the web and PC side, so I want to use axios for network requests and solve the CORS problem on the web side at the same time.

Screenshots

Image

Attempted Fixes

Can't find relevant content on the web.

System Details

➜  weiyin git:(main) ✗ wails doctor

                                
          Wails Doctor          
                                

                                                                                                                           
# Wails
Version | v2.9.2

# System
┌────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────┐
| OS           | MacOS                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                   |
| Version      | 12.7.6                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                  |
| ID           | 21H1320                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                 |
| Go Version   | go1.23.2                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                |
| Platform     | darwin                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                  |
| Architecture | amd64                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                   |
| CPU          | Intel(R) Core(TM) i7-4870HQ CPU @ 2.50GHz                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                               |
| GPU          | Chipset Model: Intel Iris Pro Type: GPU Bus: Built-In VRAM (Dynamic, Max): 1536 MB Vendor: Intel Device ID: 0x0d26 Revision ID: 0x0008 Automatic Graphics Switching: Supported gMux Version: 4.0.20 [3.2.8] Metal Family: Supported, Metal GPUFamily macOS 1 Displays: Color LCD: Display Type: Built-In Retina LCD Resolution: 2880 x 1800 Retina Framebuffer Depth: 24-Bit Color (ARGB8888) Main Display: Yes Mirror: Off Online: Yes Automatically Adjust Brightness: Yes Connection Type: Internal  AMD Radeon R9 M370X:  Chipset Model: AMD Radeon R9 M370X Type: GPU Bus: PCIe PCIe Lane Width: x8 VRAM (Total): 2 GB Vendor: AMD (0x1002) Device ID: 0x6821 Revision ID: 0x0083 ROM Revision: 113-C5670E-945 VBIOS Version: 113-C567A1-006 EFI Driver Version: 01.00.945 Automatic Graphics Switching: Supported gMux Version: 4.0.20 [3.2.8] Metal Family: Supported, Metal GPUFamily macOS 2   |
| Memory       | 16GB                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                    |
└────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────┘

# Dependencies
┌────────────────────────────────────────────────────────────────┐
| Dependency                | Package Name | Status    | Version |
| Xcode command line tools  | N/A          | Installed | 2395    |
| Nodejs                    | N/A          | Installed | 20.18.0 |
| npm                       | N/A          | Installed | 10.8.2  |
| *Xcode                    | N/A          | Available |         |
| *upx                      | N/A          | Available |         |
| *nsis                     | N/A          | Available |         |
└─────────────────── * - Optional Dependency ────────────────────┘

# Diagnosis
Optional package(s) installation details: 
  - Xcode: Available at https://apps.apple.com/us/app/xcode/id497799835
  - upx : Available at https://upx.github.io/
  - nsis : More info at https://wails.io/docs/guides/windows-installer/

 SUCCESS  Your system is ready for Wails development!

 ♥   If Wails is useful to you or your company, please consider sponsoring the project:
https://github.com/sponsors/leaanthony

Additional context

No response

@wwwAngHua wwwAngHua added the Bug Something isn't working label Feb 6, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Bug Something isn't working
Projects
None yet
Development

No branches or pull requests

1 participant