feat: chrome extension token in header
This commit is contained in:
parent
5d908470f1
commit
c951720a6e
|
|
@ -14,7 +14,7 @@
|
|||
"icons": {
|
||||
"128": "icon-128.png"
|
||||
},
|
||||
"permissions": ["activeTab"],
|
||||
"permissions": ["activeTab", "cookies", "tabs"],
|
||||
"content_scripts": [
|
||||
{
|
||||
"matches": ["http://*/*", "https://*/*", "<all_urls>"],
|
||||
|
|
|
|||
|
|
@ -1,12 +1,12 @@
|
|||
{
|
||||
"name": "postiz-extension",
|
||||
"version": "1.0.1",
|
||||
"version": "1.0.2",
|
||||
"description": "A simple chrome & firefox extension template with Vite, React, TypeScript and Tailwind CSS.",
|
||||
"scripts": {
|
||||
"build": "rm -rf dist && vite build --config vite.config.chrome.ts && zip -r extension.zip dist",
|
||||
"build:chrome": "vite build --config vite.config.chrome.ts",
|
||||
"build:firefox": "vite build --config vite.config.firefox.ts",
|
||||
"dev": "rm -rf dist && NODE_ENV=development dotenv -e ../../.env -- vite build --config vite.config.chrome.ts --mode development --watch",
|
||||
"dev": "rm -rf dist && dotenv -e ../../.env -- vite build --config vite.config.chrome.ts --mode development --watch",
|
||||
"dev:chrome": "nodemon --config nodemon.chrome.json",
|
||||
"dev:firefox": "nodemon --config nodemon.firefox.json"
|
||||
},
|
||||
|
|
|
|||
|
|
@ -29,9 +29,7 @@ chrome.runtime.onMessage.addListener(function (request, sender, sendResponse) {
|
|||
if (request.action === "loadCookie") {
|
||||
chrome.cookies.get(
|
||||
{
|
||||
url: isDevelopment
|
||||
? "http://localhost:4200"
|
||||
: "https://platform.postiz.com",
|
||||
url: import.meta.env?.FRONTEND_URL || process?.env?.FRONTEND_URL,
|
||||
name: request.cookieName,
|
||||
},
|
||||
function (cookies) {
|
||||
|
|
|
|||
|
|
@ -1,8 +1,12 @@
|
|||
import { FC, memo, useCallback, useEffect, useState } from 'react';
|
||||
import { ProviderInterface } from '@gitroom/extension/providers/provider.interface';
|
||||
import { fetchCookie } from '@gitroom/extension/utils/load.cookie';
|
||||
|
||||
const Comp: FC<{ removeModal: () => void; platform: string, style: string }> = (props) => {
|
||||
useEffect(() => {
|
||||
const Comp: FC<{ removeModal: () => void; platform: string; style: string }> = (
|
||||
props
|
||||
) => {
|
||||
const load = async () => {
|
||||
const cookie = await fetchCookie(`auth`);
|
||||
if (document.querySelector('iframe#modal-postiz')) {
|
||||
return;
|
||||
}
|
||||
|
|
@ -23,7 +27,9 @@ const Comp: FC<{ removeModal: () => void; platform: string, style: string }> = (
|
|||
iframe.style.backgroundColor = 'transparent';
|
||||
// @ts-ignore
|
||||
iframe.allowTransparency = 'true';
|
||||
iframe.src = (import.meta.env?.FRONTEND_URL || process?.env?.FRONTEND_URL) + `/modal/${props.style}/${props.platform}`;
|
||||
iframe.src =
|
||||
(import.meta.env?.FRONTEND_URL || process?.env?.FRONTEND_URL) +
|
||||
`/modal/${props.style}/${props.platform}?loggedAuth=${cookie}`;
|
||||
iframe.id = 'modal-postiz';
|
||||
iframe.style.width = '100%';
|
||||
iframe.style.height = '100%';
|
||||
|
|
@ -43,6 +49,9 @@ const Comp: FC<{ removeModal: () => void; platform: string, style: string }> = (
|
|||
}
|
||||
}
|
||||
});
|
||||
};
|
||||
useEffect(() => {
|
||||
load();
|
||||
}, []);
|
||||
return <></>;
|
||||
};
|
||||
|
|
@ -92,7 +101,11 @@ export const ActionComponent: FC<{
|
|||
<div className="g-wrapper" style={{ position: 'relative' }}>
|
||||
<div className="absolute left-0 top-0 z-[9999] w-full h-full" />
|
||||
{modal && (
|
||||
<Comp platform={provider.identifier} style={provider.style} removeModal={() => showModal(false)} />
|
||||
<Comp
|
||||
platform={provider.identifier}
|
||||
style={provider.style}
|
||||
removeModal={() => showModal(false)}
|
||||
/>
|
||||
)}
|
||||
</div>
|
||||
);
|
||||
|
|
|
|||
|
|
@ -17,9 +17,7 @@ export const sendRequest = (
|
|||
export const fetchRequestUtil = async (request: any) => {
|
||||
return (
|
||||
await fetch(
|
||||
(isDev
|
||||
? "http://localhost:4200/v1/api"
|
||||
: "https://platform.postiz.com/v1/api") + request.url,
|
||||
(import.meta.env?.FRONTEND_URL || process?.env?.FRONTEND_URL) + request.url,
|
||||
{
|
||||
method: request.method || "GET",
|
||||
headers: {
|
||||
|
|
|
|||
|
|
@ -21,7 +21,7 @@ export const baseManifest = {
|
|||
...manifest,
|
||||
host_permissions: [
|
||||
...ProviderList.map((p) => p.baseUrl + "/"),
|
||||
isDev ? "http://localhost:4200/" : "https://platform.postiz.com/",
|
||||
import.meta.env?.FRONTEND_URL || process?.env?.FRONTEND_URL + '/*',
|
||||
],
|
||||
permissions: [...(manifest.permissions || [])],
|
||||
content_scripts: [
|
||||
|
|
@ -29,9 +29,7 @@ export const baseManifest = {
|
|||
matches: ProviderList.reduce(
|
||||
(all, p) => [...all, p.baseUrl + "/*"],
|
||||
[
|
||||
isDev
|
||||
? "http://localhost:4200/*"
|
||||
: "https://platform.postiz.com/*",
|
||||
import.meta.env?.FRONTEND_URL || process?.env?.FRONTEND_URL + '/*',
|
||||
],
|
||||
),
|
||||
...rest,
|
||||
|
|
|
|||
Loading…
Reference in New Issue