H
H
houdy222019-09-27 11:44:23
Node.js
houdy22, 2019-09-27 11:44:23

Nuxt.js - How to redirect from localhost to website domain?

The situation is this:
There is a Nuxt.js (ssr/universal) application that is on the server.
When you run npm run start, it runs on localhost:3000
Question : what should I do with the htaccess file so that it redirects to the site domain and everything works when I visit the site?
PS I found some solutions, but nothing helps :(
I tried this:

RewriteEngine on

RewriteCond %{HTTP_HOST} ^example.com$
RewriteRule "(.*.(jpg|gif|png|svg|js|css|woff2))$" "http://127.0.0.1:3000/$1" [P,NC]
RewriteRule ^(.*) "http://127.0.0.1:3000/$2" [P,L]

Answer the question

In order to leave comments, you need to log in

1 answer(s)
I
Igor, 2019-09-27
@IgorPI

At least throw out Apache.
Use Nginx in proxy mode.
nginx basic configuration example

server {
    listen      			<ip>:<port>;
    server_name 			<ваш домен>;

    location / {
  proxy_pass  		http://127.0.0.1:3000;	
  #proxy_read_timeout	2s
        proxy_set_header	Host $host;
        proxy_set_header	X-Real-IP $remote_addr;
        proxy_set_header	X-Forwarded-For $proxy_add_x_forwarded_for;
        proxy_set_header	X-Forwarded-Host $server_name;
    }
}

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question