#Transition from Electron to Tauri for my app, ' session problem '

29 messages · Page 1 of 1 (latest)

kind belfry
#

Hi guys sorry if its obvious but I don't know where to start.
I stop using electron for my app to use Tauri,
From my Tauri config , I call my app URL as a webview.
And in my main.js electron file I have an important function that I would like to migrate in Tauri but I don't even know if its possible ..


const electron = require("electron");
const { BrowserWindow, session } = electron;

  session.defaultSession.webRequest.onHeadersReceived(
    { urls: ["https://*.MyAPI.com/"] },
    (details, callback) => {
      if (
        details.responseHeaders &&
        details.responseHeaders["Set-Cookie"] &&
        details.responseHeaders["Set-Cookie"].length &&
        !details.responseHeaders["Set-Cookie"][0].includes("SameSite=None")
      ) {
        details.responseHeaders["Set-Cookie"][0] =
          details.responseHeaders["Set-Cookie"][0] + "; SameSite=None; Secure";
      }
      callback({ cancel: false, responseHeaders: details.responseHeaders });
    }
  );

this function modify headers from requests from an usefull API to could set and get some cookies.

lunar quiver
#
  1. you can try using rust
#
  1. there are some tauri apis in js/ts to help you (i am not sure it would help you or not)
kind belfry
#

@lunar quiver Sorry but what did you mean by sidebundled ?

lunar quiver
#

in tauri

#

Also, I think the solution to your app isn't related to sidecar

#

you can simply make a utility function

#

to manage and append headers to each request

kind belfry
#

Are you talking about a specific API? cause my lead dev don't see how to do that

lunar quiver
#

you can do that with a utility function too

kind belfry
#

yes

#

modify* headers

lunar quiver
kind belfry
#

from a 3rd party server

lunar quiver
#

you can do the same with a utility function

#

over the tauri fetch api

lunar quiver
#

you can develop a function from this fetch

#

that will modify the headers

kind belfry
#

Right I understand but I think it's not that simple, we have an iframe in the webview, who loads an external website: (hiboutik: who manage sells, products ect...), and when we login in that iframe it's suppose to set a cookie, but cause we're calling that in an iframe et we're on an external domain, the header is not cool and that cookie don't set his-self

lunar quiver
#

and in rust wry has a function

kind belfry
#

we want to all request who's made on the webview and who call hiboutik's api, can be intercepted