Solved

Image Upload via App Proxy

elishakay
Tourist
11 1 1

Hi there,

I'm building out views for my app via App Proxy.

In the view, I'm using editorjs to upload images.

The server is running the Multer Package on NodeJS.

When I upload pictures via the View, the server is correctly saving the images.

But, the Shopify Client is not receiving the correct response.

In NodeJS, I send back:

 

 res.json({"success" : 1,
         "file": {
            "url" : `https://jungle-navigator.myshopify.com/apps/tribe/images/uploads/${req.file.filename}`            
          }
        });

 

But, when I inspect the Network tab of the client, all I see is a large HTML string coming back from the POST request.

I've also tried res.send({...}) with no luck.

Any ideas what's wrong? The server is not throwing errors, and running the code block of a successful image upload.

 

Accepted Solution (1)

elishakay
Tourist
11 1 1

This is an accepted solution.

Update: I figured it out.

I needed to set the response header as JavaScript (the response Content-Type was still still as 'application/liquid').

Here's the code that fixed it.

 res.setHeader('content-type', 'text/javascript')

View solution in original post

Reply 1 (1)

elishakay
Tourist
11 1 1

This is an accepted solution.

Update: I figured it out.

I needed to set the response header as JavaScript (the response Content-Type was still still as 'application/liquid').

Here's the code that fixed it.

 res.setHeader('content-type', 'text/javascript')