fix(frontend): endpoint env vars

This commit is contained in:
leandrofars 2024-04-22 17:37:30 -03:00
parent aa58763ad3
commit dc090a055b
8 changed files with 18 additions and 18 deletions

View File

@ -146,7 +146,7 @@ export const AuthProvider = (props) => {
redirect: 'follow'
};
let result = await fetch(process.env.NEXT_PUBLIC_REST_ENPOINT+"/auth/login", requestOptions)
let result = await fetch(process.env.NEXT_PUBLIC_REST_ENDPOINT+"/auth/login", requestOptions)
if (result.status != 200) {
throw new Error('Please check your email and password');
@ -195,7 +195,7 @@ export const AuthProvider = (props) => {
redirect: 'follow'
};
let result = await fetch(process.env.NEXT_PUBLIC_REST_ENPOINT+"/auth/admin/register", requestOptions)
let result = await fetch(process.env.NEXT_PUBLIC_REST_ENDPOINT+"/auth/admin/register", requestOptions)
if (result.status == 200) {
router.push("/auth/login")

View File

@ -21,7 +21,7 @@ export const WsProvider = (props) => {
const userVideo = useRef();
const connectionRef = useRef();
const auth = useAuth()
const socket = io(process.env.NEXT_PUBLIC_WS_ENPOINT)
const socket = io(process.env.NEXT_PUBLIC_WS_ENDPOINT)
const initialize = async () => {
// Prevent from calling twice in development mode with React.StrictMode enable

View File

@ -83,7 +83,7 @@ const Page = () => {
redirect: 'follow',
};
let result = await (await fetch(`${process.env.NEXT_PUBLIC_REST_ENPOINT}/auth/admin/exists`, requestOptions))
let result = await (await fetch(`${process.env.NEXT_PUBLIC_REST_ENDPOINT}/auth/admin/exists`, requestOptions))
let content = await result.json()
console.log("content: ", content)
if (result.status != 200) {

View File

@ -35,7 +35,7 @@ const Page = () => {
redirect: 'follow'
};
fetch(`${process.env.NEXT_PUBLIC_REST_ENPOINT}/users`,requestOptions)
fetch(`${process.env.NEXT_PUBLIC_REST_ENDPOINT}/users`,requestOptions)
.then(response => response.json())
.then(result => {
// let teste = JSON.stringify(JSON.parse(result), null, 2)

View File

@ -46,7 +46,7 @@ const Page = () => {
redirect: 'follow'
}
fetch(process.env.NEXT_PUBLIC_REST_ENPOINT+'/device', requestOptions)
fetch(process.env.NEXT_PUBLIC_REST_ENDPOINT+'/device', requestOptions)
.then(response => {
if (response.status === 401)
router.push("/auth/login")
@ -86,7 +86,7 @@ const Page = () => {
p = p - 1
p = p.toString()
fetch(process.env.NEXT_PUBLIC_REST_ENPOINT+'/device?page_number='+p, requestOptions)
fetch(process.env.NEXT_PUBLIC_REST_ENDPOINT+'/device?page_number='+p, requestOptions)
.then(response => {
if (response.status === 401)
router.push("/auth/login")
@ -115,7 +115,7 @@ const Page = () => {
}
if (id == ""){
return fetch(process.env.NEXT_PUBLIC_REST_ENPOINT+'/device', requestOptions)
return fetch(process.env.NEXT_PUBLIC_REST_ENDPOINT+'/device', requestOptions)
.then(response => {
if (response.status === 401)
router.push("/auth/login")
@ -133,7 +133,7 @@ const Page = () => {
});
}
let response = await fetch(process.env.NEXT_PUBLIC_REST_ENPOINT+'/device?id='+id, requestOptions)
let response = await fetch(process.env.NEXT_PUBLIC_REST_ENDPOINT+'/device?id='+id, requestOptions)
if (response.status === 401)
router.push("/auth/login")
let json = await response.json()

View File

@ -38,7 +38,7 @@ const Page = () => {
redirect: 'follow',
};
let result = await (await fetch(`${process.env.NEXT_PUBLIC_REST_ENPOINT}/info/general`, requestOptions))
let result = await (await fetch(`${process.env.NEXT_PUBLIC_REST_ENDPOINT}/info/general`, requestOptions))
if (result.status === 401){
router.push("/auth/login")
}else if (result.status != 200){

View File

@ -96,7 +96,7 @@ const addDeviceObj = async(obj, setShowLoading, router, updateDeviceParameters)
body: raw
};
setShowLoading(true)
let result = await (await fetch(`${process.env.NEXT_PUBLIC_REST_ENPOINT}/device/${router.query.id[0]}/any/add`, requestOptions))
let result = await (await fetch(`${process.env.NEXT_PUBLIC_REST_ENDPOINT}/device/${router.query.id[0]}/any/add`, requestOptions))
if (result.status != 200) {
if (result.status === 401){
router.push("/auth/login")
@ -131,7 +131,7 @@ const deleteDeviceObj = async(obj, setShowLoading, router, updateDeviceParameter
body: raw
};
setShowLoading(true)
let result = await (await fetch(`${process.env.NEXT_PUBLIC_REST_ENPOINT}/device/${router.query.id[0]}/any/del`, requestOptions))
let result = await (await fetch(`${process.env.NEXT_PUBLIC_REST_ENDPOINT}/device/${router.query.id[0]}/any/del`, requestOptions))
if (result.status != 200) {
if (result.status === 401){
router.push("/auth/login")
@ -481,7 +481,7 @@ const getDeviceParameters = async (raw) =>{
body: raw
};
let result = await (await fetch(`${process.env.NEXT_PUBLIC_REST_ENPOINT}/device/${router.query.id[0]}/any/parameters`, requestOptions))
let result = await (await fetch(`${process.env.NEXT_PUBLIC_REST_ENDPOINT}/device/${router.query.id[0]}/any/parameters`, requestOptions))
if (result.status != 200) {
if (result.status === 401){
router.push("/auth/login")
@ -505,7 +505,7 @@ const getDeviceParameterInstances = async (raw) =>{
body: raw
};
let result = await (await fetch(`${process.env.NEXT_PUBLIC_REST_ENPOINT}/device/${router.query.id[0]}/any/instances`, requestOptions))
let result = await (await fetch(`${process.env.NEXT_PUBLIC_REST_ENDPOINT}/device/${router.query.id[0]}/any/instances`, requestOptions))
if (result.status != 200) {
throw new Error('Please check your email and password');
}else if (result.status === 401){
@ -778,7 +778,7 @@ const getDeviceParameterInstances = async (raw) =>{
body: raw
};
let result = await (await fetch(`${process.env.NEXT_PUBLIC_REST_ENPOINT}/device/${router.query.id[0]}/any/get`, requestOptions))
let result = await (await fetch(`${process.env.NEXT_PUBLIC_REST_ENDPOINT}/device/${router.query.id[0]}/any/get`, requestOptions))
if (result.status != 200) {
if (result.status === 401){
router.push("/auth/login")
@ -1028,7 +1028,7 @@ const getDeviceParameterInstances = async (raw) =>{
setOpen(false)
setShowLoading(true)
let result = await (await fetch(`${process.env.NEXT_PUBLIC_REST_ENPOINT}/device/${router.query.id[0]}/any/set`, requestOptions))
let result = await (await fetch(`${process.env.NEXT_PUBLIC_REST_ENDPOINT}/device/${router.query.id[0]}/any/set`, requestOptions))
if (result.status != 200) {
if (result.status === 401){
router.push("/auth/login")
@ -1171,7 +1171,7 @@ const getDeviceParameterInstances = async (raw) =>{
body: raw
};
setShowLoading(true)
let result = await fetch(`${process.env.NEXT_PUBLIC_REST_ENPOINT}/device/${router.query.id[0]}/any/operate`, requestOptions)
let result = await fetch(`${process.env.NEXT_PUBLIC_REST_ENDPOINT}/device/${router.query.id[0]}/any/operate`, requestOptions)
let content = await result.json()
if (result.status != 200) {
setShowLoading(false)

View File

@ -84,7 +84,7 @@ const handleOpen = () => {
}
fetch(`${process.env.NEXT_PUBLIC_REST_ENPOINT}/device/${router.query.id[0]}/any/${method}`, requestOptions)
fetch(`${process.env.NEXT_PUBLIC_REST_ENDPOINT}/device/${router.query.id[0]}/any/${method}`, requestOptions)
.then(response => response.text())
.then(result => {
if (result.status === 401){