Commit ed3a0c5f by Arjun Jhukal

updated the server menu base query and next config

parent d1a80c88
......@@ -21,7 +21,7 @@ const nextConfig: NextConfig = {
return [
{
source: '/api/backend/:path*', // Requests to /api/backend/* from your frontend
destination: 'https://app.bdwebai.com/api/:path*', // Will be rewritten to your Laravel API
destination: 'https://app.bdwebai.com/:path*', // Will be rewritten to your Laravel API
},
];
},
......
......@@ -3,4 +3,4 @@ import { serverBaseQuery } from "./serverBaseQuery";
export async function getAllMenus(): Promise<MenuResponse> {
return serverBaseQuery("/api/general/menus");
}
\ No newline at end of file
}
// import { RootState } from "@/hooks/store";
// import { fetchBaseQuery } from "@reduxjs/toolkit/query/react";
// export const baseQuery = fetchBaseQuery({
// baseUrl: process.env.NEXT_PUBLIC_BASE_URL,
// credentials: 'include',
// prepareHeaders(headers, { getState }) {
// const token = (getState() as RootState).auth.access_token;
// headers.set("Accept", "application/json");
// headers.set("Content-Type", "application/json");
// if (token) {
// headers.set("Authorization", `Bearer ${token}`);
// }
// return headers;
// },
// });
// src/services/baseQuery.ts
import { RootState } from "@/hooks/store";
import { fetchBaseQuery } from "@reduxjs/toolkit/query/react";
export const baseQuery = fetchBaseQuery({
baseUrl: process.env.NEXT_PUBLIC_BASE_URL,
credentials: 'include',
prepareHeaders(headers, { getState }) {
// Use your Next.js frontend URL + proxy path
// Example: https://sweepstake.webjuwa.com/api/backend OR localhost:3000/api/backend
baseUrl:
(process.env.NEXT_PUBLIC_FRONTEND_URL || "") + "/api/backend",
credentials: "include",
prepareHeaders: (headers, { getState }) => {
const token = (getState() as RootState).auth.access_token;
headers.set("Accept", "application/json");
headers.set("Content-Type", "application/json");
if (token) {
headers.set("Authorization", `Bearer ${token}`);
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment