-
Notifications
You must be signed in to change notification settings - Fork 27.2k
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
SSR redirect destition with basePath #18984
Comments
Tested building and starting the app locally and here's what I noticed. ❌ Redirecting in getServerSideProps dont works (basePath ignored). Tested the app from a docker image and here's what I noticed. ❌ Redirecting in getServerSideProps dont works (basePath ignored). The docker image running in a container pickup the env variables because I can reach my API that is using the env variable. next.config.js const basePath = process.env.BASE_PATH ?? '';
const environment = process.env.ENVIRONMENT ?? 'UNKNOWN';
const apiBaseUri = process.env.API_BASE_URI ?? '';
/**
* The main Next.js configuration.
* see: https://nextjs.org/docs/api-reference/next.config.js/environment-variables
*/
module.exports = {
basePath,
publicRuntimeConfig: {
basePath,
environment,
i18n: { lookupCookie: 'locale' },
apiBaseUri
}
}; Dockerfile #
# Create 'BUILD' image
#
FROM node:15.1.0-alpine AS BUILD
WORKDIR /build
# install build dependencies
COPY package.json .
COPY yarn.lock .
RUN yarn install
# build the application
COPY public/ public/
COPY src/ src/
COPY next.config.js .
RUN yarn build
#
# Create 'RUNTIME' image
#
FROM node:15.1.0-alpine
WORKDIR /app
# install the nextjs runtime and application
COPY --from=BUILD /build/.next/ .next/
COPY --from=BUILD /build/public/ public/
COPY --from=BUILD /build/next.config.js .
COPY --from=BUILD /build/package.json .
COPY --from=BUILD /build/yarn.lock .
RUN yarn add next
#CMD yarn start
CMD ["yarn", "start"]
EXPOSE 3000 |
I've changed my Dockerfile and the problem is still there when running in a container. FROM node:15.1.0-alpine
# setting working directory. All the path will be relative to WORKDIR
WORKDIR /app
# installing dependencies
COPY package.json .
COPY yarn.lock .
RUN yarn install
# copying source files
COPY . .
# building app
RUN yarn build
# running the app
CMD [ "yarn", "start" ]
# expose port
EXPOSE 3000 |
Hi, this should be resolved after #18988 is landed |
The above PR is now available in |
I still have problems with "next": "^10.0.2-canary.12". Tested building and starting the app locally and here's what I noticed. ✔️ Redirecting in getServerSideProps works (basePath not ignored). Tested the app from a docker image and here's what I noticed. ✔️ Redirecting in getServerSideProps works (basePath not ignored). |
I still have problems with "next": "10.0.2-canary.9". Tested building and starting the app locally and here's what I noticed. ✔️ Redirecting in getServerSideProps works (basePath not ignored). Tested the app from a docker image and here's what I noticed. ✔️ Redirecting in getServerSideProps works (basePath not ignored). |
Looks like the above mentioned error with |
This issue has been automatically locked due to no recent activity. If you are running into a similar issue, please create a new issue with the steps to reproduce. Thank you. |
Bug report
Describe the bug
We are using basePath in our application and from / we are directing to /[goalType] with Server Side Rendering. We are determining the goalType base on a API fetch and the language use in the app. GoalType can be AS or GE. If I use basePath '/resource-finder' and trying it, the page is hitted but I'm redirected to '/AS'. It should redirect me to '/resource-finder/AS'. I have the same behavior if using router.push('/AS').
Here's the getServerSideProps function
Expected behavior
Usins basePaht '/resource-finder should redirect me to '/resource-finder/AS' if using '/resource-finder/' path in the browser. This basePath is ignored in getServerSideProps and router.push().
System information
The text was updated successfully, but these errors were encountered: