Questions tagged [nextjs-rewrites]
29 questions
4
votes
0 answers
NextJS, How inject Authorization header before next.config rewrites happens?
I'm using NextJS to build our Frontend.
The NextJS API just provides basic checks and then redirects to proper micro-services.
But I'm struggling to find the proper approach.
Since we are using Next 12 I think next.config rewrites is a nice fit, but…

Guillermo F. Lopez
- 385
- 3
- 13
3
votes
0 answers
NextJS rewrites error while proxying a request to the backend
I'm trying to proxy a request to a backend with Next rewrites.
next.config.js:
async rewrites() {
return [
{
source: "/api/:path*",
destination: "http://somedomain.loc/api/:path*",
},
]
},
/etc/host:
127.0.0.1 …

Vladyslav
- 51
- 4
3
votes
0 answers
NextJs localized rewrites with query parameters reloads the browser and throws failed to load script error
I'm facing an issue while using rewrites and query parameters. I'll describe it further below. if I've lost you at any point during the explanation feel free to ask for a clarification.
Expected result
What I'm trying to achieve is localizing a…

Wesley Janse
- 1,244
- 1
- 7
- 14
2
votes
0 answers
Nextjs middleware rewrite page props sometimes undefined
Hope this finds yo well.
I'm working on a multilang website with translated URLs. I'm on Next.js 13.3
To handle the translated rotues i'm using a middleware. ( I have a large number of rewrites/redirects and the config ones entirely broke client…

Tofuu
- 45
- 1
- 7
2
votes
0 answers
Next js Redirect to other domains Not Working
I can redirect to the path in same domain but enable to redirect if domain is different. This error only occurs on firebase hosting and is working fine on localhost with yarn dev.
code:
const router =…

Abdullah Qureshi
- 161
- 8
2
votes
0 answers
rewrites in next js working fine in local, but not working after deployment in vercel
this is how my next.config.js looks like =>
{
async rewrites() {
return [
{
source: '/:path*',
destination: `/:path*`,
},
{
source: '/sell',
destination: `${NEXT_PUBLIC_APP_URL}/sell`,
…

user9783371
- 21
- 3
2
votes
1 answer
Next.js rewrites + custom dynamical header for axios on the server-side
How i can do dynamical header for axios on the serve-side? I want to make functionality of cities, without edit nextjs folder structure. Rewrities from nextjs solves my problem, but I can't set the header for axios request functions on the server…

Danial
- 45
- 3
1
vote
0 answers
Read Write file in next js api
I want to Write a example.txt file in a __dirname + "/testfolder/example.txt" but next js build version not allow to write. so how can I solve this problem ?
When I try to Write any file the it's log
Error: EISDIR: illegal operation on a directory,…

Nahid hasan Sagor
- 11
- 2
1
vote
0 answers
The provided `as` value (/product-ui/order/EC0701HICR) is incompatible with the `href` value (/order/[orderId])
The url server will append the path to navigate the modules. I get an error when nextjs custom server appends prefix: /product-ui I don't understand what's wrong with my custom server file about router mapping
I tried to configure the URL conversion…

SUN
- 13
- 3
1
vote
0 answers
NextJs rewrites does not proxy API calls in getServerSideProps
I am using react-query prefetchQuery and NextJS (v.13) getServerSideProps along with its rewrites option in next.config.js file to proxy API calls.
The rewrites looks like this:
async rewrites() {
return [
{
source: "/api/:slug*",
…

Ali Baghban
- 517
- 1
- 5
- 13
0
votes
1 answer
NextJS 13 Error: fetch failed Unhandled Runtime Error
When I try to fetch data in NextJS 13 an error encountered Unhandled Runtime Error.
what is the Error here.
async function getPosts() {
const res = await fetch(
"https://jsonplaceholder.typicode.com/posts?_limit=10"
);
if (!res.ok) {
…

Abraham Johannes
- 21
- 2
0
votes
2 answers
Getting 404 Not Found error when refreshing dynamic page in DirectAdmin deployment
I'm encountering a "404 Not Found" error when trying to refresh a dynamic page in my Next.js application deployed on DirectAdmin. The error occurs only when I attempt to refresh the page, but navigating to it from a different route works fine.
Here…

Amin Ghazi
- 55
- 1
- 7
0
votes
0 answers
Nextjs Middleware rewrite routes and won't redirect even when user is logged in
I am facing an issue in nextjs middleware I am building a ecommerce app that has three actors [admin , customer , vendor] in middleware i have a function that decode the token from header cookies and then returns the data containing user email , id…

Abdullah moiz
- 112
- 1
- 8
0
votes
0 answers
Multi-tenancy redirect issue on client-side nextjs
I am working on multi-tenancy feature for our white label apps in NextJS.
Each white label app will have a subdomain for example (apple.abc.org, samsung.abc.org).
In the middleware, based on the subdomain I need to redirect it to a single page.
I am…

Shreyas Chorge
- 127
- 1
- 6
0
votes
0 answers
Using rewrites to connect projects, works on local but not on server
I am using rewrites to connect projects on Vercel. I can run the program on localhost without issue. I can even rewrite local main project to a deployed project. When I try to rewrite from deployed main project to deployed secondary project, the…

Miles Donald
- 3
- 2