Skip to content
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

PDF tab preview not working. #3760

Closed
Krrost opened this issue Mar 8, 2023 · 4 comments
Closed

PDF tab preview not working. #3760

Krrost opened this issue Mar 8, 2023 · 4 comments

Comments

@Krrost
Copy link

Krrost commented Mar 8, 2023

Hi,

I have vscode-server in a docker container, hosted on my domain through reverse proxy, with LatexWorkshop and Texlive installed.

Everything seems to be ok, but I can't see the pdf preview in the tab, there is the pdf viewer, but nothing inside, here's a screenshot. If I go to get the file, the pdf is generated normally.

LatexWorkshop log:

[Commander] VIEW command invoked with mode: tab.
[Manager] Current workspace folders: ["file://%WS1%","file://%WS2%"]
[Manager] Found root file from active editor: %WS2%/aaa.tex
[Manager] Keep using the same root file: %WS2%/aaa.tex
[Structure] Structure updated with 0 root sections for %WS2%/aaa.tex .
[Viewer][Panel] Internal PDF viewer at https://mydomain.com/proxy/40451/viewer.html?file=pdf..xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx .
[Cacher][Watcher] Watched %WS2%/aaa.pdf .
[Viewer] Open PDF tab for file://%WS2%/aaa.pdf
[Viewer] Handle data type: open

The pdf is accessible from the address https://mydomain.com/proxy/40451/....., it correctly shows the pdf in a browser tab.

So I have a problem with the tab preview, like it can't read the pdf.
Do you happen to know why?

Thanks

@James-Yu
Copy link
Owner

James-Yu commented Mar 8, 2023

I’ve no idea why. You may need to provide devtools log.

@Krrost
Copy link
Author

Krrost commented Mar 8, 2023

Thanks for the reply. Here's the log:

image

So there's a problem with how I am hosting the service I guess.
Sorry I'm not experienced in this stuff, any ideas?
Thanks again

@James-Yu
Copy link
Owner

James-Yu commented Mar 8, 2023

I’ve no idea why this might happen even with the log. I figure it might be related to your docket network config, yet I don’t think I may further help as I do not have this use case. The strange thing is, the viewer worked fine in browser but not in vscode. Therefore this may also be an issue of vscode, rather than the extension.

@James-Yu James-Yu closed this as completed Mar 8, 2023
@minghaoL1
Copy link

I came across the same problem (nothing in the pdf tab and the request is also /proxy/build/pdf.worker.js), the PR #3639 did not fix the problem in my case(v9.7.0). I follow the idea in this issue to record the proxy port into cookie and rewrite /proxy/build/pdf.worker.js to /proxy/[proxy_port]/build/pdf.worker.js. It works for me : )

I hosted code server on example.com/public and here is my nginx configuration:

configuration

location ^~/public/ {
  proxy_set_header Host $host;
  proxy_set_header Upgrade $http_upgrade;
  proxy_set_header Connection upgrade;
  proxy_set_header Accept-Encoding gzip;
  proxy_pass http://public/;

  location ~* ^/public/proxy/(?<proxy_port>[^\n\r\/]+)(?<proxy_path>.*)$ {
    default_type text/html;
    if ($proxy_port !~* ^([1-9]|[1-9][0-9]|[1-9][0-9][0-9]|[1-9][0-9][0-9][0-9]|[1-5][0-9][0-9][0-9][0-9]|6[0-5][0-5][0-3][0-5])$) {
      rewrite ^/public/proxy/(.*)$ /public/proxy/$cookie_proxy_port/$1 permanent; # rewrite URI like  /public/proxy/build/pdf.worker.js 
    }
    if ($proxy_path = ''){
      set $proxy_path '/'; #force to use relative path
    }
    add_header Set-Cookie 'proxy_port=$proxy_port; Path=/public';
    proxy_http_version 1.1;
    proxy_pass http://127.0.0.1:$proxy_port$proxy_path;
    proxy_set_header Host $http_host;
    proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
    proxy_set_header X-Real_IP $remote_addr;
    proxy_set_header User-Agent $http_user_agent;
    proxy_set_header Accept-Encoding "";
    proxy_buffering off;
    #websocket
    set $to_upgrade "";
    set $to_connection "";
    if ($http_upgrade = "websocket"){
      set $to_upgrade "websocket";
      set $to_connection "Upgrade";
    }
    proxy_set_header Upgrade $to_upgrade;
    proxy_set_header Connection $to_connection;
    proxy_read_timeout 86400;
  }
}

@github-actions github-actions bot locked as resolved and limited conversation to collaborators Apr 15, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants