Skip to content

PDF content blocked over /proxy/<port>/ #2413

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
c0ppelius opened this issue Dec 7, 2020 · 13 comments
Closed

PDF content blocked over /proxy/<port>/ #2413

c0ppelius opened this issue Dec 7, 2020 · 13 comments
Labels
bug Something isn't working extension The issue needs to be fixed in the extension
Milestone

Comments

@c0ppelius
Copy link

c0ppelius commented Dec 7, 2020

First, let me thank you for a great product. My general workflow involves a lot of drawing and frequent use of latex. An iPad makes a perfect travel companion once it comes with a functional latex IDE. Code-server makes that happen. The only issue is the built-in pdf viewer. (Other pdf viewer extensions can be substituted but do not have built in synctex nor behave as smoothly.) In Latex Workshop extension currently, the pdf viewer listens on localhost: which is not accessible.

The best VS Code extension for latex is currently Latex Workshop. Unfortunately, the developers there have chosen to not support code-server. As such, one needs to hack in a solution to point their pdf server at code-server.

Of the two methods, available subpaths or subdomains, I chose subpaths. I modified the source to include a code-server flag and url (https://code.example.com below) in the extension settings. The result defaults to the existing setup if the code-server flag is not enabled. Otherwise, it directs the pdf server to serve the pdf file at https://code.example.com/proxy/<port>/ Here is a complete example URL generated:

https://code.example.com/proxy/41467/viewer.html?file=pdf..JTJGaG9tZSUyRm1hdHRoZXdyb2JlcnRiYWxsYXJkJTJGbGV0dGVycyUyRkFsZXhfRHVuY2FuJTJGZHVuY2FuX2JyZWFrdGhyb3VnaC5wZGY

The behavior in code-server is shown here and if I try to open directly in Firefox I see the toolbox for the pdf viewer but no content. The pdf server is poking through but the pdf itself is not.

My approach is very similar to that of @lukas-hetzenecker taken at #James-Yu/LaTeX-Workshop#2341 except that subdomains are implemented there.

  • Web Browser: Chrome
  • Local OS: Ubuntu 18.04
  • Remote OS: Debian Buster
  • Remote Architecture: x86
  • code-server --version: 3.7.4

When adding the extension to your code-server install, I have found it loaded incompletely (even with multiple versions of the official release) unless one rigorously follows the following steps:

  • Uninstall an existing Latex Workshop extension
  • Close any existing browsers
  • Reload code-server
  • Install from the vsix file from the command line
  • Reload code-server
  • Browse back to your install.

You can find the modified vsix here.

@c0ppelius
Copy link
Author

c0ppelius commented Dec 7, 2020

Some progress. Removing the content security policy on the generated html file allowed rendering in code-server to look like the external browser. Inspecting the source, it looks like some js files are not running to generate content, probably viewer.js.

@nhooyr nhooyr added bug Something isn't working extension The issue needs to be fixed in the extension labels Dec 8, 2020
@code-asher
Copy link
Member

code-asher commented Dec 8, 2020 via email

@code-asher
Copy link
Member

Related: #1862

@c0ppelius
Copy link
Author

c0ppelius commented Dec 8, 2020

If you used the latest version of https://github.com/c0ppelius/latex_code-server, then that might be a problem. I ended going back using subdomains instead of subpaths in the current version. The original still has subpaths.

I should emphasize that subdomains works out of the box (from https://github.com/lukas-hetzenecker/LaTeX-Workshop) so subpaths isn't a pressing issue.

I would guess that somewhere in there the /proxy/port/ is messing up formatting of a query of the url but I haven't found it yet.

@c0ppelius
Copy link
Author

Root viewer.js vs proxy path viewer.js is a problem. It previously could not locate it and other scripts. But, it doesn't seem to solve the issue. In fact, the behavior seems the same. The tool bar renders but not the pdf inside the main container.

@jsjoeio jsjoeio added this to the Backlog milestone Apr 29, 2021
@t-huyeng
Copy link

t-huyeng commented May 6, 2021

@c0ppelius any news on getting the pdf viewer working? I think this could be a really a nice piece to push code-server even more.

@c0ppelius
Copy link
Author

c0ppelius commented May 6, 2021

95% all the issues lie in how the latex-workshop is written (the url for pdf viewer server in particular) so this isn't a code-server problem. It is only a problem if you want to use the built in pdf viewer with the latex-workshop extension (say because you like the synctex integration and don't want to write) while using code-server. If you specifically want a working pdf viewer in the latex-workshop extension, you can modify the source code as shown here and compile the vsix yourself. I did this and have been using it without issue for months.

@lamnguyenx
Copy link

95% all the issues lie in how the latex-workshop is written (the url for pdf viewer server in particular) so this isn't a code-server problem. It is only a problem if you want to use the built in pdf viewer with the latex-workshop extension (say because you like the synctex integration and don't want to write) while using code-server. If you specifically want a working pdf viewer in the latex-workshop extension, you can modify the source code as shown here and compile the vsix yourself. I did this and have been using it without issue for months.

Hi c0ppelius. Could you push the latest compiled VSIX to GitHub? I guess many people like me would also need it!

@c0ppelius
Copy link
Author

It was too much to keep up this updated. A few months ago when an old VSIX didn't work properly I threw in the towel and moved to vim. Hopefully with recent news there will be a push from MSFT to get all extensions working properly in a remote environment.

Best of luck.

@modaresimr
Copy link

I have created the extension working in 9.2.2
https://github.com/modaresimr/LaTeX-Workshop/blob/master/latex-workshop-9.2.2.vsix

@jdrusso
Copy link

jdrusso commented Jan 24, 2023

Thanks for that @modaresimr -- unfortunately, that build doesn't work for me (code-server 4.5.1, from the lscr.io/linuxserver/code-server:latest Docker image). When I try to open a PDF for preview, a blank tab with a message that it's opening the PDF opens for a bit, then the tab closes.

@modaresimr
Copy link

I have merged it with the latest code of latex workshop James-Yu/LaTeX-Workshop#3639
In the new version it has been resolved :)

@modaresimr
Copy link

It is already merged to the code and in the next version of latex workshop you can see it :)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working extension The issue needs to be fixed in the extension
Projects
None yet
Development

No branches or pull requests

8 participants