rlidwka / sinopia

Private npm repository server
5.5k stars 655 forks source link

Cross-Domain Error #362

Open pafq opened 8 years ago

pafq commented 8 years ago

Hello.

I configure Sinopia with the default port 4873. When I try to access the Web Interface with this port everything runs Ok. Now, I have a Apache Server and configure a VirtualHost to redirect the http://npm.myCompany.pt to http://npm.myCompany.pt:4873. When I try to access to http://npm.first.pt I'm getting the following error on 2 requests (font request):

Font from origin 'http://npm.myCompany.pt:4873' has been blocked from loading by Cross-Origin Resource Sharing policy: No 'Access-Control-Allow-Origin' header is present on the requested resource. Origin 'http://npm.first.pt' is therefore not allowed access.

This is my VirtualHost configuration:

< VirtualHost *:80> ServerName npm.myCompany.pt

ProxyPass / http://npm.myCompany.pt:4873/

< /VirtualHost>

Can any one help me? Thanks, kintas

pelallemant commented 8 years ago

Did you find a solution ? I'm facing the same problem.

pafq commented 8 years ago

Hi @pelallemant

I let the Sinopia running on port 4873 and change the Apache Config to:

< VirtualHost *:80> ServerName npm.myCompany.pt

ServerSignature Off

ProxyPreserveHost On

# Ensure that encoded slashes are not decoded but left in their encoded state.
# http://doc.gitlab.com/ce/api/projects.html#get-single-project
AllowEncodedSlashes Off

<Location />
  Order deny,allow
  Allow from all

  ProxyPassReverse http://127.0.0.1:4873
  ProxyPassReverse http://npm.myCompany.pt/
</Location>

# Apache equivalent of nginx try files
# http://serverfault.com/questions/290784/what-is-apaches-equivalent-of-nginxs-try-files
# http://stackoverflow.com/questions/10954516/apache2-proxypass-for-rails-app-gitlab
RewriteEngine on

#Forward all requests to gitlab-workhorse
RewriteRule .* http://127.0.0.1:4873%{REQUEST_URI} [P,QSA,NE]

< /VirtualHost>

pelallemant commented 8 years ago

In fact I made a mistake in the DNS configuration, it's fine now.

Thanks