deezy5456
11/25/2022, 11:40 AMgetRoutingComponent()
does not render in chrome extension, but does when run via npm start
or npm run build && serve -s {{path}}
My current project involves a chrome extension running a react app in its popup. It is in this react app that I would like users to register or login using supertokens. To this end, I followed your getting started guide. As a minimal example, I simply initialize SuperTokens
and call getRoutingComponent()
, which IIUC, returns an element that renders the login/registration UI.
That being said, when I use npm start
or npm run build && serve -s {{path}},
I do see the login UI being rendered.
When turning on debug logs and logging the return value of getRoutingComponent()
, I do see SuperTokens
being initialized as well as the return value of the function call not being null
. Instead, I can see it is of type react.element
with a props path
of index.html
and supertokensInstance
being the supertokens instance.
This led me to the conclusion that soemthing's wrong with my configuration since it's working with both the devserver and as a production build being served.
I've searched for similar use cases and indeed found some who were using supertokens in a chrome extension but nothing comparable hererp_st
11/25/2022, 11:52 AMrp_st
11/25/2022, 11:52 AMdeezy5456
11/25/2022, 11:52 AMporcellus
11/25/2022, 11:54 AMdeezy5456
11/25/2022, 11:54 AMchrome-extension://{{ either random string or some hash }}
, whereas the value of websitedomain I used to initialize SuperTokens was referring to a specific websiteporcellus
11/25/2022, 11:54 AMporcellus
11/25/2022, 11:55 AMdeezy5456
11/25/2022, 11:56 AMnormalizedURLDomain.js
deezy5456
11/25/2022, 11:56 AMdeezy5456
11/25/2022, 11:58 AMporcellus
11/25/2022, 12:16 PMporcellus
11/25/2022, 12:17 PMporcellus
11/25/2022, 12:18 PM/auth
route in the extension and it doesn't show up?rp_st
11/25/2022, 2:21 PMrp_st
11/25/2022, 2:22 PMrp_st
11/25/2022, 2:22 PMporcellus
11/25/2022, 2:48 PMporcellus
11/25/2022, 2:49 PMrp_st
11/25/2022, 2:49 PMrp_st
11/25/2022, 2:49 PMdeezy5456
11/25/2022, 3:25 PMdeezy5456
11/25/2022, 3:28 PMdeezy5456
11/25/2022, 3:28 PMrp_st
11/25/2022, 3:29 PMdeezy5456
11/25/2022, 4:54 PMdeezy5456
11/25/2022, 4:59 PMchrome
offers an identity api to deal with the shortcomings of running in a browser extension, generating a ephemeral URL for the extension, but I'd really like to use supertokens for this projects.
In case you have any guide or someone that has already set this up, lmk.rp_st
11/25/2022, 5:00 PMdeezy5456
11/25/2022, 5:04 PMdjarran
12/08/2022, 12:45 AMdeezy5456
12/09/2022, 7:44 AMdjarran
12/09/2022, 9:50 AM// This event is fired each time the URL of a tab changes
chrome.tabs.onUpdated.addListener(function(tabId, changeInfo, tab) {
let newUrl = changeInfo.url;
if (newUrl.includes('http://chrome-extension//<id>/options.html')) {
const stringSplit = newUrl.split('?')
const queryParams = stringSplit[1]
chrome.tabs.update(tabId, {url: `chrome-extension://<id>/options.html?${queryParams}`})
}
console.log(newUrl)
});
djarran
12/09/2022, 9:51 AMdjarran
12/09/2022, 9:52 AMrp_st
12/09/2022, 10:13 AM