CORS policy problem with Zebra Printers

// Expert user has replied.
B Brian Wilson 11 months ago
470 3 0

I suppose this isn't directly browser print related, but I am attempting to either use BrowserPrint which I can't get working at all or simply a post request to http://{printerIP}/pstprnt to print qr codes on a Zebra ZT230. 

 

The post request method is working successfully in development, but the moment I deploy my application and either attempt to hit the printer with a post request at HTTP or HTTPS, I am blocked by CORS policy, and I am reading that this is because the printer does not send back a header with Access-Control-Allow-Origin: "*".

 

It's a bit frustrating that there is such a lack of documentation and nothing but outdated SDK's surrounding these printers. Is there anyone who has successfully deployed an app or knows how to work past this CORS error? If this can work, I wouldn't touch browser print with a 10 foot pole. I just need to be able to print a label on demand from my web app, and like I said, it's working in development but not in deployment.

 

I am using a Next.js (React) app with an ASP.NET Cor Web API backend. I am working behind a pretty strict corporate proxy as well, and the client-side request I showed above to the pstprnt endpoint is the only thing that seemed to even have a chance of working, and then the CORS issue popped up.

 

This issue is mentioned here:

 

https://supportcommunity.zebra.com/s/question/0D56S00009DYjcjSAD/has-browserprint-stopped-working-in-chrome-due-to-cors-issue?language=en_US

 

Please register or login to post a reply

3 Replies

S Steven Si

There is a mini webservice built into the firmware of Zebra printers that accepts the http://{printerIP}/pstprnt POST request for printing. This mini webservice has not been updated for awhile and does not handle more modern security improvements in browsers. That's why the CORS errors pop up, though the print will happen correctly. The pstprint is still an option for printing from browsers, if the web application can accept or ignore this particular CORS error.

For the Browser Print, it is a better option than the pstprnt. The Browser Print supports Windows, MacOS and Android, and supports the network, USB or Bluetooth (for Android) connected printers. Besides, the Browser Print gets updated on a regular basis. The Browser Print requires a local client app runs in background that bridges the communication between the web app running in the browser and the printers connected via network, USB or Bluetooth (for Android).

B Brian Wilson

Hi there and thank you for your response.

I have to say the installation of an app is not ideal for any app that is intended to scale widely, though it’s not egregious either given that getting an installation on any computers that need the browser print bridge app is not a huge deal.

Do you know if the Asp.Net SDK “Zebra.Printing.SDK” (or whatever it is, sorry I’m not at the computer right now) has any issues with this? If I were to utilize it in an ASP.NET core web api from server side rather than client side, maybe that would bypass any issues?

I will have to test it tomorrow to find out I suppose..

S Steven Si

The Zebra.Printer.SDK is meant for the .NET Framework for building desktop applications. Instead of building your own Webservice, the simplest and easiest way for printing from a web app would be the SendFileToPrinter API, which is a REST API that can be called from anywhere in any programming language. See this article for more details about this API: Use the SendFileToPrinter API for Your Cloud-Based Printing Needs.

CONTACT
Can’t find what you’re looking for?