You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I've been following Lama Dev's Social Networking Tutorial
but running it in docker containers, which he doesn't do in the tutorial. One of those containers is Traefik, which acts as a gateway for 80 and 443 and one more for an admin panel, but I haven't opened 8800 for the API because I was under the understanding that React should still see it in docker's default network, I'm not sure if the 405 is coming from the API or if that's still in React, what I've read on 405 says it's usually in the client and the line that logs the error is in React but it's in a failed call, so maybe the 405 message is an Axios response, it's saying the connection isn't allowed. I'm not sure what else to try changing?
It seems to work fine locally in Development But not in Production, It's usually up at https:geoLARP.com, if it's down for a few minutes I'm probably trying a rebuild on the server and it'll be back up shortly.
I've also wondered if I need to remove CORS, he has them in the repo but never mentions them in the video..
The only environment variable from dev to prod that I think might make a difference is LOCAL_HOST, I'm changing it to geolarp.com, should I be including the HTTP:// too?
I started to try through PostMan, but currently, I've not left the API open to the public, I was expecting React would see it over the docker default network by just changing the proxy to the API container. so I've changed localhost:8800 to mernlama:8800 in an .env file
Regist.jsx
importaxiosfrom"axios";import{useRef}from"react";import{useHistory}from"react-router";import"./register.css";exportdefaultfunctionRegister(){constusername=useRef();constemail=useRef();constpassword=useRef();constpasswordAgain=useRef();consthistory=useHistory();consthandleClick=async(e)=>{e.preventDefault();// console.log(email.current.value);if(passwordAgain.current.value!==password.current.value){passwordAgain.current.setCustomValidity('PassWords do not Match');}else{constuser={username: username.current.value,email: email.current.value,password: password.current.value,};try{awaitaxios.post("/auth/register",user);history.push("/login");}catch(err){console.log(err);}}};return(<divclassName="login"><divclassName="loginWrapper"><divclassName="loginLeft"><h3className="loginLogo">geoLARP</h3><spanclassName="loginDesc">
GeoLocated
</span><spanclassName="loginDesc">
Live Action Role Playing
</span></div><divclassName="loginRight"><formclassName="loginBox"onSubmit={handleClick}><inputplaceholder="Username"requiredclassName="loginInput"ref={username}/><inputplaceholder="please use a disposable Email"type='email'requiredclassName="loginInput"ref={email}/><inputplaceholder="Password"type='password'requiredminLength="6"className="loginInput"ref={password}/><inputplaceholder="Password Again"type='password'requiredclassName="loginInput"ref={passwordAgain}/><buttonclassName="loginButton"type='submit'>Sign Up</button><buttonclassName="loginRegisterButton">
Log into Account
</button></form></div></div></div>);}
expressAPI/routes/auth.js
constrouter=require('express').Router();constUser=require('../models/User');constbcrypt=require('bcrypt');// REGISTERrouter.post('/register',async(req,res)=>{try{// generate a salty passwordconstsalt=awaitbcrypt.genSalt(10);consthashedPassword=awaitbcrypt.hash(req.body.password,salt);// create a new userconstnewUser=newUser({username: req.body.username,email: req.body.email,password: hashedPassword,});// save the user and respondconstuser=awaitnewUser.save();console.log(user);res.status(200)// .json({ message: 'Registered User with API AUTH Route', user: user._id });.json(user);}catch(err){res.status(500).json(err);}});// GET /api/auth// LOGINrouter.post('/login',async(req,res)=>{try{// find the userconstuser=awaitUser.findOne({email: req.body.email});// check if the user exists!user&&res.status(404).json('User not found');// check if the password is correctconstvalidPassword=awaitbcrypt.compare(req.body.password,user.password);!validPassword&&res.status(400).json('Invalid Password');// respond with the userres.status(200).json(user);}catch(err){res.status(500).json(err);}});// GET /api/auth/loginmodule.exports=router;// export default router;
UPDATE
I've started looking at the NGINX configuration. If I understand correctly the React proxy is just for local development. So I've been looking at how Nginx Configures the Proxy Pass-Through.. These are the 2 I've tried so far, the commented out is what I tried first, but I don't have the experience with Nginx to know which settings I really need. I got Bad GateWay with the commented-out settings.
link to repo
link to bug report
I've been following Lama Dev's Social Networking Tutorial
but running it in docker containers, which he doesn't do in the tutorial. One of those containers is Traefik, which acts as a gateway for 80 and 443 and one more for an admin panel, but I haven't opened 8800 for the API because I was under the understanding that React should still see it in docker's default network, I'm not sure if the 405 is coming from the API or if that's still in React, what I've read on 405 says it's usually in the client and the line that logs the error is in React but it's in a failed call, so maybe the 405 message is an Axios response, it's saying the connection isn't allowed. I'm not sure what else to try changing?
It seems to work fine locally in Development But not in Production, It's usually up at https:geoLARP.com, if it's down for a few minutes I'm probably trying a rebuild on the server and it'll be back up shortly.
I've also wondered if I need to remove
CORS
, he has them in the repo but never mentions them in the video..The only environment variable from dev to prod that I think might make a difference is LOCAL_HOST, I'm changing it to geolarp.com, should I be including the
HTTP://
too?I started to try through PostMan, but currently, I've not left the API open to the public, I was expecting React would see it over the docker default network by just changing the proxy to the API container. so I've changed
localhost:8800
tomernlama:8800
in an.env
fileRegist.jsx
expressAPI/routes/auth.js
UPDATE
I've started looking at the NGINX configuration. If I understand correctly the React proxy is just for local development. So I've been looking at how Nginx Configures the Proxy Pass-Through.. These are the 2 I've tried so far, the commented out is what I tried first, but I don't have the experience with Nginx to know which settings I really need. I got Bad GateWay with the commented-out settings.
nginx.conf
The text was updated successfully, but these errors were encountered: