mirror of
https://github.com/TryGhost/Ghost.git
synced 2025-01-27 22:49:56 -05: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 changed files with 5 additions and 3 deletions
|
@ -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…
Add table
Reference in a new issue