Next.js 13+重定向到/或主页在部署的环境中,但不是本地,刷新时。任何帮助将不胜感激。
举例来说:
如果我刷新mysite.com/aboutus,它会将我带到部署站点上的测试环境中的mysite.com。
有些组件是服务器端呈现的,有些是客户端呈现的。
如果我正在运行localhost:3000/aboutus
网址仍然在顶部mysite.com,但该网站显示mysite.com(主页)。
编辑:如果我添加trailingSlash: true
,它会把我带到https://example.com:5000/aboutus/
,显然是坏了。所以我的假设是页面在某个时候被缓存到服务器?
我在openshift中使用nginx部署。
nginx conf文件:
# Set worker processes based on your CPU cores, nginx does not benefit from setting more than that
worker_processes auto;
# Load perl module for env var subsitution
load_module modules/ngx_http_perl_module.so;
# read in env variable
env runtimeEnvironment;
env applicationName;
# number of file descriptors used for nginx
# the limit for the maximum FDs on the server is usually set by the OS.
# if you don't set FD's then OS settings will be used which is by default 2000
worker_rlimit_nofile 100000;
# change pid loc for lower privileged account
pid /tmp/nginx.pid;
# Log errors/emerg/crit to syslog (splunk)
# Log crit events to local container output
error_log syslog:server=splunk-dmz.nvthbs.local:21514 error;
error_log /var/log/nginx/error.log warn;
# provides the configuration file context in which the directives that affect connection processing are specified.
events {
# determines how many clients will be served per worker
# max clients = worker_connections * worker_processes
# max clients is also limited by the number of socket connections available on the system (~64k)
worker_connections 4000;
# optimization to serve multiple clients per thread
use epoll;
# enable multiple connections
multi_accept on;
}
http {
# set env vars
perl_set $runtimeenv 'sub { return $ENV{"runtimeEnvironment"};}';
perl_set $appName 'sub { return $ENV{"applicationName"};}';
# limit the number of connections per single IP - DDOS Protection
limit_conn_zone $binary_remote_addr zone=conn_limit_per_ip:10m;
# limit the number of requests for a given session - DDOS Protection
limit_req_zone $binary_remote_addr zone=req_limit_per_ip:10m rate=200r/s;
# if the request body size is more than the buffer size, then the entire (or partial)
# request body is written into a temporary file
# affects any POST actions sent to nginx
client_body_buffer_size 128k;
# buffer size for reading client request header
client_header_buffer_size 10K;
# maximum number and size of buffers for large headers to read from client request
large_client_header_buffers 4 256k;
# time a server will wait for client header to be sent after request
client_header_timeout 12;
# time a server will wait for client body to be sent after request
client_body_timeout 12;
# timeout for keep-alive connections to client
keepalive_timeout 30;
# timeout between two reads - keeps memory free -- default 60
send_timeout 10;
# set log format for access logs
log_format custom 'Application:$appname Environment:$runtimeenv '
'- $remote_addr - $remote_user [$time_local] '
'"$request" $status $body_bytes_sent '
'"$http_referer" "$http_user_agent" '
'"$http_x_forwarded_for" $request_id ';
# Condition map to reduce access logging and eliminate 200 / 300
map $status $loggable {
~^[23] 0;
default 1;
}
# Access log configuration with conditional statement applied to reduce logging events
# access_log syslog:server=splunk-dmz.nvthbs.local:21514,facility=local7,tag=nginx custom if=$loggable;
# access logging all events
access_log syslog:server=splunk-dmz.nvthbs.local:21514,facility=local7,tag=nginx custom;
# copies data between one FD and other from within the kernel
# faster than read() + write()
sendfile on;
# send headers in one piece - more performant
tcp_nopush on;
# don't buffer data sent, good for small data bursts in real time
tcp_nodelay on;
# enable gzip compression
gzip on;
gzip_min_length 1024;
gzip_comp_level 2;
gzip_vary on;
gzip_disable msie6;
gzip_proxied expired no-cache no-store private auth;
gzip_types
# text/html is always compressed by HttpGzipModule
text/css
text/javascript
text/xml
text/plain
text/x-component
application/javascript
application/x-javascript
application/json
application/xml
application/rss+xml
application/atom+xml
font/truetype
font/opentype
application/vnd.ms-fontobject
image/svg+xml;
# allow the server to close connection on non responding client, this will free up memory
reset_timedout_connection on;
# number of requests client can make over keep-alive
# having high value can be especially beneficial in testing load generation
# Consider evaluating for production
keepalive_requests 100000;
# Set temp paths - need to be explicitly set to /tmp due to permissions
proxy_temp_path /tmp/proxy_temp;
client_body_temp_path /tmp/client_temp;
fastcgi_temp_path /tmp/fastcgi_temp;
uwsgi_temp_path /tmp/uwsgi_temp;
scgi_temp_path /tmp/scgi_temp;
include /etc/nginx/mime.types;
default_type application/octet-stream;
server {
# zone which we want to limit by upper values, we want limit whole server
limit_conn conn_limit_per_ip 10;
limit_req zone=req_limit_per_ip burst=10 nodelay;
listen 8080;
listen 5000 ssl;
ssl_certificate /etc/ssl/crt/tls.crt;
ssl_certificate_key /etc/ssl/key/tls.key;
ssl_protocols TLSv1.2;
default_type application/octet-stream;
root /usr/share/nginx/apps;
location / {
try_files $uri $uri/ /index.html =404;
add_header 'Access-Control-Allow-Origin' '*' always;
add_header 'Cache-Control' 'no-store';
# proxy_pass https://mysite.site.com:5000;
# proxy_http_version 1.1;
# proxy_set_header Upgrade $http_upgrade;
# proxy_set_header Connection 'upgrade';
# proxy_set_header Host $host;
# proxy_cache_bypass $http_upgrade;
}
#test
#test
# To allow POST on static pages
error_page 405 =200 $uri;
}
}
字符串
1条答案
按热度按时间fcg9iug31#
问题出在nginx的实现上。
为了查找.html文件,需要另外一行“$uri.html "。
在nginx.conf中:
字符串
https://github.com/vercel/next.js/discussions/10522#discussioncomment-884013