mirror of
https://github.com/TryGhost/Ghost.git
synced 2024-12-25 11:55:03 +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) {
|
||||
if (event.origin !== '*') {
|
||||
// return;
|
||||
@ -20,7 +22,7 @@ window.addEventListener('message', async function (event) {
|
||||
if (data.action === 'getUser') {
|
||||
try {
|
||||
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();
|
||||
respond(null, json);
|
||||
@ -31,7 +33,7 @@ window.addEventListener('message', async function (event) {
|
||||
|
||||
if (data.action === 'hideComment') {
|
||||
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',
|
||||
body: JSON.stringify({
|
||||
comments: [{
|
||||
@ -52,7 +54,7 @@ window.addEventListener('message', async function (event) {
|
||||
|
||||
if (data.action === 'showComment') {
|
||||
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',
|
||||
body: JSON.stringify({
|
||||
comments: [{
|
||||
|
Loading…
Reference in New Issue
Block a user