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

SignatureDoesNotMatch when creating redirects with special characters #218

Open
marcus13371337 opened this issue Dec 4, 2020 · 5 comments
Labels
bug Something isn't working priority: medium

Comments

@marcus13371337
Copy link

marcus13371337 commented Dec 4, 2020

Hello!

I'm using your plugin to deploy our website to an S3 bucket. When I've implemented some redirects I get the following error:

SignatureDoesNotMatch: The request signature we calculated does not match the signature you provided. Check your key and signing method.
s3.js:700 Request.extractError

One example of the redirects I'm trying to create:

createRedirect({
   fromPath: `/p/123456/`,
   toPath: '/argument-f%C3%B6r-testning/p/123456/', //special character ö is encoded inside
   isPermanent: true
})

Which in code looks like this:

 await createPage({
    path: node.fields.slug,
    component: resolve(
       __dirname,
      `../../src/templates/myPage.tsx`
     ),
     context: {
       id: node.id,
     },
 });

 await createRedirect({
      fromPath: `/p/${node.productNumber}/`,
      toPath: node.fields.slug,
      isPermanent: true,
  });

Note that I'm using the same slug as I'm doing when creating the page. What am I doing wrong?

@YoshiWalsh
Copy link
Collaborator

Just as a sanity check, does it work when your path does not contain special characters? SignatureDoesNotMatch can indicate incorrect credentials.

Also, what's your config look like? Are you using generateRedirectObjectsForPermanentRedirects?

@marcus13371337
Copy link
Author

Hi,

Yes, it normally works for other files (the error is thrown after some files have been uploaded).

@marcus13371337
Copy link
Author

Actually, now when I'm looking at it, we do not escape the characters in the node.fields.slug-field, so the value of that is actually: '/argument-för-testning/p/123456/', which is the path that is printed in s3.redirectsObject.json. Should that be escaped?

@marcus13371337
Copy link
Author

Added encoding and it seems to work much better. However, that seems to me as an inconsistency compared to how gatsby's createPage works. Also, a better error message would be really helpful as I've been struggling with this for a while.

Love the plugin, super simple and works like a charm for our page! Keep up the good work

@YoshiWalsh
Copy link
Collaborator

The AWS docs don't mention any requirement to escape the value, but I guess it makes sense that it has to be URL safe. We should implement escaping. Still, I'm surprised that you get a SignatureDoesNotMatch error, that seems very strange.

Unfortunately aws-sdk doesn't often provide useful error messages, and if we tried to read them and provide more helpful ones it would really just be guesswork.

@YoshiWalsh YoshiWalsh added bug Something isn't working priority: medium labels Dec 4, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working priority: medium
Projects
None yet
Development

No branches or pull requests

2 participants