Skip to content

Commit

Permalink
feaat: dynamic url
Browse files Browse the repository at this point in the history
  • Loading branch information
Angga Maulana authored and Angga Maulana committed Mar 18, 2023
1 parent d292e68 commit 60322b0
Show file tree
Hide file tree
Showing 5 changed files with 14 additions and 5 deletions.
7 changes: 7 additions & 0 deletions next.config.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
const conf = {
env: {
prefixs: process.env.PREFIXS,
},
};

module.exports = conf;
6 changes: 3 additions & 3 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -38,9 +38,9 @@
"yup": "^1.0.1"
},
"scripts": {
"start": "NODE_ENV=production NODE_PORT=4000 node server.js",
"start_staging": "NODE_ENV=production NODE_PORT=4001 node server.js",
"start_dev": "NODE_ENV=production NODE_PORT=4002 node server.js",
"start": "NODE_URL=cerberus NODE_ENV=production NODE_PORT=4000 node server.js",
"start_staging": "NODE_URL=staging NODE_ENV=production NODE_PORT=4001 node server.js",
"start_dev": "NODE_URL=dev NODE_ENV=production NODE_PORT=4002 node server.js",
"build": "next build",
"export": "next export",
"dev": "next dev",
Expand Down
2 changes: 2 additions & 0 deletions pages/_app.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ import "styles/tailwind.css";
import { Provider } from "react-redux";
import { PersistGate } from "redux-persist/integration/react";
import AlertProvider from "./alertProvider";
import { api } from "../services/api";

Router.events.on("routeChangeStart", (url) => {
document.body.classList.add("body-page-transition");
Expand Down Expand Up @@ -41,6 +42,7 @@ const MyApp = (props) => {
=========================================================
`);
document.insertBefore(comment, document.documentElement);
api.defaults.baseURL = `http://bcastarx.com/${process.env.prefixs}/api/`
},[])

const getInitialProps = async ({ Component, router, ctx }) => {
Expand Down
2 changes: 1 addition & 1 deletion server.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ const next = require('next')

const dev = process.env.NODE_ENV !== 'production'
const hostname = 'localhost'
const port = process.env.PORT || 4000
const port = process.env.NODE_PORT || 4000
// when using middleware `hostname` and `port` must be provided below
const app = next({ dev, hostname, port })
const handle = app.getRequestHandler()
Expand Down
2 changes: 1 addition & 1 deletion services/api.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import axios from 'axios';
import Cookies from 'js-cookie';

const api = axios.create({
baseURL: `http://bcastarx.com/dev/api/`,
baseURL: `http://bcastarx.com/cerberus/api/`,
headers: {
'Accept': 'application/json',
'Content-Type': 'application/json',
Expand Down

0 comments on commit 60322b0

Please sign in to comment.