wailsapp / wails

Create beautiful applications using Go
https://wails.io
MIT License
25.26k stars 1.22k forks source link

Iframe load other website can't save cookie? #2536

Open songdemei opened 1 year ago

songdemei commented 1 year ago

Description

I add a iframe element in page . Open the app. View website ,that OK. But ,when I login to website ,they can't save my cookie??

To Reproduce

how can I store cookie in iframe?

Expected behaviour

I add a iframe element in page . Open the app. View website ,that OK. But ,when I login to website ,they can't save my cookie??

Screenshots

No response

Attempted Fixes

No response

System Details

mac os

Additional context

No response

helloxz commented 1 year ago

I had a similar problem, and I was fine in dev mode. But when I compiled and packaged macos I couldn't save the cookies

mateothegreat commented 1 year ago

You're going to be running in to a wall anytime you're trying to "share" cookies between iframes given policy restrictions, hostnam'ing, path'ing, etc.

By "can't save the cookie", what is the result exactly? Check the response payload from your login method(s) and see if the cookie is definitely being returned and then check the policies it's requesting to be enforced.

songdemei commented 1 year ago

When I open my other site using iframe,and login .They can't keep login stat ,but I use browser ,they work fine.

leaanthony commented 1 year ago

@songdemei - have you tried with the latest version?

songdemei commented 1 year ago

@songdemei - have you tried with the latest version?

My wails version is 2.2 , I update to 2.5.1[latest version] When I run it using "wails dev" they can't start up , some error like this: WailsContext.m:221:28: error: property 'fraudulentWebsiteWarningEnabled' not found on object of type 'WKPreferences *' What can I do next?

leaanthony commented 1 year ago

Please paste the output of wails doctor 👍

songdemei commented 1 year ago

` bogon:sxserver songdemei$ wails doctor Wails CLI v2.5.1

SUCCESS Done.

System

OS | MacOS
Version | 10.14.6 ID | 18G9323 Go Version | go1.19.4 Platform | darwin
Architecture | amd64

Wails

Version | v2.5.1

Dependencies

Dependency | Package Name | Status | Version Xcode command line tools | N/A | Installed | 2354
Nodejs | N/A | Installed | 16.3.0
npm | N/A | Installed | 7.15.1
Xcode | N/A | Available |
upx | N/A | Installed | upx 3.96 *nsis | N/A | Available |

Diagnosis

Your system is ready for Wails development! Optional package(s) installation details:

songdemei commented 1 year ago

I create a empty project,output like this:

bogon:myproject songdemei$ wails dev Wails CLI v2.5.1

Executing: go mod tidy • Generating bindings: Done. • Installing frontend dependencies: Done. • Compiling frontend: Done.

frontend@0.0.0 dev vite

Port 5173 is in use, trying another one...

VITE v3.2.6 ready in 387 ms

Vite Server URL: http://localhost:5174/ ➜ Local: http://localhost:5174/ ➜ Network: use --host to expose Running frontend DevWatcher command: 'npm run dev' Building application for development... • Generating bindings: Done. • Compiling application:

github.com/wailsapp/wails/v2/internal/frontend/desktop/darwin

WailsContext.m:221:28: error: property 'fraudulentWebsiteWarningEnabled' not found on object of type 'WKPreferences *'

Build error - exit status 2 No version running, build will be retriggered as soon as changes have been detected watching: /xxx/xxx/xxx/xxx/myproject 。。。。。 Using DevServer URL: http://localhost:34115 Using Frontend DevServer URL: http://localhost:5174/ Using reload debounce setting of 100 milliseconds

To develop in the browser and call your bound Go methods from Javascript, navigate to: http://localhost:34115

songdemei commented 1 year ago

Please paste the output of wails doctor 👍

I can't run it yet! @leaanthony

songdemei commented 1 year ago

I down to V2.3.1 they run success. Now I see the request header and response header like this(login method):

Request POST /login/login HTTP/1.1 Accept: application/json, text/javascript, /; q=0.01 Content-Type: application/x-www-form-urlencoded; charset=UTF-8 Origin: http://127.0.0.1:8080 Referer: http://127.0.0.1:8080/login Content-Length: 30 Host: 127.0.0.1:8080 Accept-Language: zh-cn User-Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10_14_6) AppleWebKit/605.1.15 (KHTML, like Gecko) wails.io Accept-Encoding: gzip, deflate Connection: keep-alive X-Requested-With: XMLHttpRequest

Response HTTP/1.1 200 OK Set-Cookie: beegosessionID=37125b3dbeb51ebd9d03b8f4f9591c1d; Path=/; Max-Age=86400; HttpOnly; SameSite=Strict Content-Type: text/plain; charset=utf-8 Content-Length: 67 Date: Sun, 28 May 2023 08:40:56 GMT Server: beegoServer:2.0.0

And next ,I location to website root path: location.href='/' The request header loss my cookie:

Request GET / Referer: http://127.0.0.1:8080/login Accept: text/html,application/xhtml+xml,application/xml;q=0.9,/;q=0.8 User-Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10_14_6) AppleWebKit/605.1.15 (KHTML, like Gecko) wails.io Upgrade-Insecure-Requests: 1

songdemei commented 1 year ago

The possible reason is that cross domain. But when I open http://localhost:5174/ use my chrome browser ,that is OK,but use wails can't send cookie.

frontRocha commented 2 months ago

@songdemei Did you manage to solve it?