saleor: Bug: Creating an upload an image in dashboard, thumbnail url is http://localhost:8000

What are you trying to achieve?

I have saleor deployed with kubernetes. When I create a product and upload an image for that product in the dashboard, then go back to the products listing, the dashboard makes a request to http://localhost:8000/thumbnail/someImage, because that’s what the api responds with for the thumbnail url, even though the MEDIA_URL is configured, and the API_URI is configured. Not sure what I’m missing in my configuration and image build.

If I call the thumbnail endpoint myself with curl, it will generate the thumbnail and then display it, but for some reason when the image is uploaded the thumbnail url for the product is populated with localhost:8000.

Core and Dashboard version 3.8.4.

The queries below were performed against my test instance at : https://api.slr.rwx.dev/graphql/. I would be happy to supply a token to this test instance if anyone would like for debugging.

root@saleor-84c754f9c6-fqvq7:/app# env |grep localhost
# nooutput

Steps to reproduce the problem

  1. create a product mutation
mutation {
  productCreate(input: {name: "TEST PRODUCT", category: "Q2F0ZWdvcnk6MQ==", productType: "UHJvZHVjdFR5cGU6MQ=="}) {
    product {
      id
      name
      thumbnail{url}
    }
  }
}
  1. create product media mutation
mutation {
  productMediaCreate(input: {alt:"",mediaUrl:"http://ecx.images-amazon.com/images/I/415W2YHAJ4L._AA160_.jpg",product:"UHJvZHVjdDo4"}){__typename}
}
  1. get products query
{
  products(first:1){
    edges{
      node{
        id , slug, channel, name,
        variants{
          name, id
        },
        media{
          id, url
        },
        thumbnail{
            url
        }
      }
    }
  }
}

results

{
  "data": {
    "products": {
      "edges": [
        {
          "node": {
            "id": "UHJvZHVjdDo4",
            "slug": "test-product",
            "channel": null,
            "name": "TEST PRODUCT",
            "variants": [],
            "media": [
              {
                "id": "UHJvZHVjdE1lZGlhOjY=",
                "url": "https://cdn.slr.rwx.dev/media/products/415W2YHAJ4L._AA160__563c1bdb.jpg"
              }
            ],
            "thumbnail": {
              "url": "http://localhost:8000/thumbnail/UHJvZHVjdE1lZGlhOjY=/256/"
            }
          }
        }
      ]
    }
  },
  "extensions": {
    "cost": {
      "requestedQueryCost": 5,
      "maximumAvailable": 50000
    }
  }
}

What did you expect to happen?

thumbnail url should start with baseurl of api.

Logs

No response

Environment

Saleor version: 3.8.4 OS and version: Docker images built as shown in my readme

About this issue

  • Original URL
  • State: open
  • Created 2 years ago
  • Reactions: 3
  • Comments: 20 (1 by maintainers)

Most upvoted comments

I think it would be nice if the shop domain was configurable via an environment variable.

The current solution still presents a problem, if Saleor is running behind a reverse proxy (Nginx) then one must enable SSL via ENABLE_SSL=True to get the https:// prefix in the Shop.url field. Which doesn’t make much sense when running behind a proxy, and breaks communication to other services in the cluster. It would be enough to somehow use https:// in the URL, without having to enable full-fledged SSL support.

~Current workaround is to leave SSL off and set up a redirect in Nginx.~

Edit: ~Apparently Saleor dashboard doesn’t process multiple 301 redirects. So thumbnails will not show in dashboard.~ Edit: Chromium auto-upgrades HTTP requests to HTTPS, bypassing Nginx redirect altogether.

So the workaround for thumbnails in the dashboard is to just let Chromium auto-upgrade HTTP to HTTPS. No redirect necessary.

@skymoore that looks like something related to #11117.

@magul I agree. I think the issue really is that in 3.8.4, there is no place to set this in the dashboard, so a new user like myself, doesn’t even know this setting exists. It seems to me like it should be an environment variable.

@tiendq Glad you got it sorted, yeah I don’t know anything about cloud, I only learned about this because I was developing this k8s deployment for saleor

For me the domain update mutation doesn’t update the URL…

mutation {
  shopDomainUpdate(
    input: { domain: "www.example.com", name: "Saleor" }
  ) {
    shop {
      domain {
        host
        url
        sslEnabled
      }
      name
    }
  }
}

Result:

{
  "data": {
    "shopDomainUpdate": {
      "shop": {
        "domain": {
          "host": "www.example.com",
          "url": "http://localhost:8000/",
          "sslEnabled": false
        },
        "name": "Saleor"
      }
    }
  }
}

@akhial For me it only works once per container start. Try restarting the container.

For me the domain update mutation doesn’t update the URL…

mutation {
  shopDomainUpdate(
    input: { domain: "www.example.com", name: "Saleor" }
  ) {
    shop {
      domain {
        host
        url
        sslEnabled
      }
      name
    }
  }
}

Result:

{
  "data": {
    "shopDomainUpdate": {
      "shop": {
        "domain": {
          "host": "www.example.com",
          "url": "http://localhost:8000/",
          "sslEnabled": false
        },
        "name": "Saleor"
      }
    }
  }
}

Curl command to update the site domain:

export TOKEN="someReallyLongTokenGoesHere"
# set the name and domain in the mutation
curl 'https://api.slr.rwx.dev/graphql/' \
    -X POST \
	-H 'Content-Type: application/json' \
	-H "authorization-bearer: $TOKEN" \
    --data-raw '{"operationName":"ShopDomainUpdate","variables":{"input":{"name":"saleor","domain":"api.slr.rwx.dev"}},"query":"mutation ShopDomainUpdate($input:SiteDomainInput!){shopDomainUpdate(input:$input){__typename}}"}'