Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Cannot edit posts in a deployed version of the app #20

Open
sakhmedbayev opened this issue Jan 13, 2020 · 5 comments
Open

Cannot edit posts in a deployed version of the app #20

sakhmedbayev opened this issue Jan 13, 2020 · 5 comments

Comments

@sakhmedbayev
Copy link

Whenever I try to edit any post in a deployed version of the app I get this error:

This XML file does not appear to have any style information associated with it. The document tree is shown below.
<Error>
<Code>AccessDenied</Code>
<Message>Access Denied</Message>
<RequestId>BSDA3BD410F2SDSDCD252A</RequestId>
<HostId>
d/kZyIzqZC1RQmmPLOSDRutO14SDSDSu5AGbNXzyvStZ2i2kCKYvoA8J+qNuul2bYapCUey2uabdmzvfwk=
</HostId>
</Error>

Everything works as expected while running the app locally.

It seems that something happens between the user's click on the "Edit post" button and the edit post rendering. There is also this error in the console:

commons.js:26 Uncaught TypeError: document.createElement(...).getContext is not a function
    at Object.<anonymous> (commons.js:26)
    at i (commons.js:26)
    at Object.<anonymous> (commons.js:26)
    at i (commons.js:26)
    at Object.<anonymous> (commons.js:26)
    at i (commons.js:26)
    at Object.<anonymous> (commons.js:26)
    at i (commons.js:26)
    at Object.<anonymous> (commons.js:26)
    at Object.<anonymous> (commons.js:26)
@Bulletninja
Copy link

Bulletninja commented Apr 8, 2020

I had a similar issue deploying a proyect with s3. although it was a more "manual" setup. The solution i found then had to do with 2 things:
One related to cloudfront distributions. But after deploying this project i don't see any new distributions. The other one i don't remember if the solution was s3 rules and/or editing permissions by hand (each and every "app/page" that has some kind of "slug"), but can't use that either, since it doesn't seem like we get an s3 bucket after deploying.

Edit: I documented the first solution here https://bulletninja.com/gatsby-s3-cloudfront-redirection

@Bulletninja
Copy link

I also get this when visiting the admin:
Screen Shot 2020-04-07 at 22 28 09

@Bulletninja
Copy link

I think i just solved it. Went to rewrites and redirects and added this:
Screen Shot 2020-04-07 at 23 04 57
Then it worked.

@Bulletninja
Copy link

I know i said it works. But i meant you don't get the Access Denied message to be more precise

I don't get it, but i also don't get the article, the key here seems to be related to both redirection parameters i show in my answer above, and reach router:

<EditPage path="/editpage/:id/:title/*" />

But i'm not sure how to pass those to /editpost/index.html

@Bulletninja
Copy link

After inspecting requests more closely (not saying i understand each step, because i don't). I figured there were other redirects missing. Seems to me like there are two competing behaviors, one is the file-system(-like), and the other the web behavior. There is no problem locally without the redirects. Probably gatsby develop and gatsby serve do the right thing for us, but in s3 the file-system(-like) behavior wins unless we add the redirects.
The first redirect solves part of the issue, since what we actually one is in that index.html file, but navigating gatsby pages is not just about those index.html files, but mainly about files named page-data.json. I'd love to say i know how those work, but i think i need to read this first (yes, i haven't read it :( )

What i did is added this rewrite:
Screen Shot 2020-04-12 at 23 46 28

And it finally showed things and was editable. I'm guessing other pages, like editpage, need a similar treatment.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants