CORS: Access-Control-Allow-Headers

Hello,

I'm trying to use the Javascript SDK (version 3) to run the ListTableRowsCommand. Everything seems to be working fine in terms of passing in credentials and parameters, but I keep getting a CORS issue due to the x-amz-content-sha256 request header.

The error says:

Access to fetch at https://honeycode.us-west-2.amazonaws.com/workbooks/WORKBOOK_ID_XXX/tables/TABLE_ID_XXX/rows/list from origin localhost:3000 has been blocked by CORS policy: Request header field x-amz-content-sha256 is not allowed by Access-Control-Allow-Headers in preflight response.

I understand the CORS error, however I don't know where I'm supposed to update the Server response headers to allow x-amz-content-sha256.

Any thoughts?

Thank you,
Christian

import { HoneycodeClient, ListTableRowsCommand } from "@aws-sdk/client-honeycode";


function App() {
  const [loading, setLoading] = useState(true);
  const [rows, setRows] = useState([]);

  const client = new HoneycodeClient({
    region: process.env.REACT_APP_HONEYCODE_REGION,
    credentials: {
      accessKeyId: process.env.REACT_APP_AWS_ACCESS_KEY_ID,
      accessSecretKey: process.env.REACT_APP_AWS_SECRET_ACCESS_KEY
    }
  })

  const params = {
    tableId: process.env.REACT_APP_HONEYCODE_TABLE_ID,
    workbookId: process.env.REACT_APP_HONEYCODE_WORKBOOK_ID
  }

  const command = new ListTableRowsCommand(params);

  useEffect(async () => {    
    try {
      const data = await client.send(command);
      setRows(data);
    } catch (error) {
      console.error(error);
    }
  }, [client, command])

Hi @Chri-df42, welcome to the community! :slight_smile: :honeybee:

Thanks for your post and sharing your code as well. Our team took a look, and this appears to be a configuration issue caused by custom request headers, rather than an issue within the Honeycode APIs.

Since the source of this issue is outside of Honeycode, we recommend exploring developer forums that address this particular CORS error. (Doing a search, different threads offer suggestions to resolve this error.)

If you continue to have trouble after trying recommendations in those threads, please submit an issue report to us after seeing the error (do so by clicking on the Help icon > "Report an issue"). This provides logs to us to take a deeper look.

Thank you for looking into it, Alyssa. I've opened a ticket over in the Github repository for this specific Amazon SDK I'm using. There were similar issues mentioned with other APIs. Unfortunately, it requires actual changes on the server that I don't have access to.

Here's a link to the Github issue in case anyone else comes across this: https://github.com/aws/aws-sdk-js-v3/issues/3275