mirror of
https://github.com/TryGhost/Ghost.git
synced 2024-12-26 04:13:30 +03:00
Updated message handler for dynamic admin urls
refs https://github.com/TryGhost/Team/issues/1664
This commit is contained in:
parent
a6842e8a20
commit
e1a3adea6a
@ -1,3 +1,5 @@
|
|||||||
|
const adminUrl = window.location.href.replace('auth-frame/', '');
|
||||||
|
|
||||||
window.addEventListener('message', async function (event) {
|
window.addEventListener('message', async function (event) {
|
||||||
if (event.origin !== '*') {
|
if (event.origin !== '*') {
|
||||||
// return;
|
// return;
|
||||||
@ -20,7 +22,7 @@ window.addEventListener('message', async function (event) {
|
|||||||
if (data.action === 'getUser') {
|
if (data.action === 'getUser') {
|
||||||
try {
|
try {
|
||||||
const res = await fetch(
|
const res = await fetch(
|
||||||
'https://admin.egg/blog/ghost/api/canary/admin/users/me/'
|
adminUrl + 'api/canary/admin/users/me/'
|
||||||
);
|
);
|
||||||
const json = await res.json();
|
const json = await res.json();
|
||||||
respond(null, json);
|
respond(null, json);
|
||||||
@ -31,7 +33,7 @@ window.addEventListener('message', async function (event) {
|
|||||||
|
|
||||||
if (data.action === 'hideComment') {
|
if (data.action === 'hideComment') {
|
||||||
try {
|
try {
|
||||||
const res = await fetch('https://admin.egg/blog/ghost/api/canary/admin/comments/' + data.id + '/', {
|
const res = await fetch(adminUrl + 'api/canary/admin/comments/' + data.id + '/', {
|
||||||
method: 'PUT',
|
method: 'PUT',
|
||||||
body: JSON.stringify({
|
body: JSON.stringify({
|
||||||
comments: [{
|
comments: [{
|
||||||
@ -52,7 +54,7 @@ window.addEventListener('message', async function (event) {
|
|||||||
|
|
||||||
if (data.action === 'showComment') {
|
if (data.action === 'showComment') {
|
||||||
try {
|
try {
|
||||||
const res = await fetch('https://admin.egg/blog/ghost/api/canary/admin/comments/' + data.id + '/', {
|
const res = await fetch(adminUrl + 'api/canary/admin/comments/' + data.id + '/', {
|
||||||
method: 'PUT',
|
method: 'PUT',
|
||||||
body: JSON.stringify({
|
body: JSON.stringify({
|
||||||
comments: [{
|
comments: [{
|
||||||
|
Loading…
Reference in New Issue
Block a user