Skip to content

Getting a 401 #48

@iJKTen

Description

@iJKTen

After cloning the repo and performing the following steps

  1. Running npm inatll
  2. Renaming the env file to .env
  3. Updating the .env file with the claude API key CLAUDE_API_KEY=your_claude_api_key
  4. Making sure I have credits
  5. Running a test curl command to confirm the API key works
#!/bin/sh
curl https://api.anthropic.com/v1/messages \
     --header "x-api-key: $ANTHROPIC_API_KEY" \
     --header "anthropic-version: 2023-06-01" \
     --header "content-type: application/json" \
     --data \
'{
    "model": "claude-sonnet-4-5",
    "max_tokens": 1024,
    "messages": [
        {"role": "user", "content": "Hello, Claude"}
    ]
}'
  1. Running the project locally by running this command shopify app dev --use-localhost
  2. Installing the latest shopify app npm install -g @shopify/cli@latest
  3. After running shopify app dev --use-localhost --reset and setting up everything I stop the server
  4. I start the server again by running shopify app dev --use-localhost
  5. I make sure this happens I make sure this happens ? --use-localhost requires a certificate for localhost`. Generate it now?

Yes, use mkcert to generate it`

  1. The app is installed and I enable embed for my theme
  2. I open the browser and see the icon to start the chat
  3. I start the chat by asking can you show me snowboards
  4. I get a response Sorry, I couldn't process your request. Please try again later.
  5. In the console I see
React Router │ Connected to MCP with 5 tools
React Router │ Connected to customer MCP with 4 tools
React Router │ Error processing streaming request: AuthenticationError: 401
{"error":"AuthenticationError","location":"proxy","log_level":"warn","description":"The proxy threw an 'AuthenticationError' error","reason":"Invalid X-Api-Key
header format. See https://openai-proxy.shopify.io","details":null}
React Router │     at APIError.generate
(file:///Users/jaikirdatt/dev/shop-chat-agent/node_modules/@anthropic-ai/sdk/src/core/error.ts:67:14)
React Router │     at Anthropic.makeStatusError
(file:///Users/jaikirdatt/dev/shop-chat-agent/node_modules/@anthropic-ai/sdk/src/client.ts:443:28)
React Router │     at Anthropic.makeRequest
(file:///Users/jaikirdatt/dev/shop-chat-agent/node_modules/@anthropic-ai/sdk/src/client.ts:678:24)
React Router │     at processTicksAndRejections (node:internal/process/task_queues:103:5) {

My package.json has

  "dependencies": {
    "@prisma/client": "^6.2.1",
    "@react-router/fs-routes": "^7.10.1",
    "@react-router/node": "^7.10.1",
    "@react-router/serve": "^7.10.1",
    "@shopify/app-bridge-react": "^4.1.6",
    "@shopify/shopify-app-react-router": "^1.0.0",
    "@shopify/shopify-app-session-storage-prisma": "^7.0.0",
    "isbot": "^5.1.0",
    "prisma": "^6.2.1",
    "react": "^18.2.0",
    "react-dom": "^18.2.0",
    "react-router": "^7.10.1",
    "vite-tsconfig-paths": "^5.0.1",
    "@anthropic-ai/sdk": "^0.71.2",
    "dotenv": "^16.3.1"
  },
  "devDependencies": {
    "@react-router/dev": "^7.10.1",
    "@shopify/api-codegen-preset": "^1.1.1",
    "@shopify/polaris-types": "^1.0.0",
    "@types/eslint": "^9.6.1",
    "@types/node": "^22.2.0",
    "@types/react": "^18.2.31",
    "@types/react-dom": "^18.2.14",
    "@typescript-eslint/eslint-plugin": "^6.7.4",
    "@typescript-eslint/parser": "^6.7.4",
    "eslint": "^8.38.0",
    "eslint-import-resolver-typescript": "^3.6.1",
    "eslint-plugin-import": "^2.28.1",
    "eslint-plugin-jsx-a11y": "^6.7.1",
    "eslint-plugin-react": "^7.33.2",
    "eslint-plugin-react-hooks": "^4.6.0",
    "prettier": "^3.2.4",
    "typescript": "^5.2.2",
    "vite": "^6.2.2"
  },

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions