deploy React + VITE and Express

I have my React application with VITE and an express server to send emails, when I want to deploy it raises the server but I can't get it to read the static files from /dist
No description
No description
No description
51 Replies
Mazzanga
Mazzanga6mo ago
3161844c-1cfc-470c-995a-24c2de301990
Brody
Brody6mo ago
can you please share your repo?
Mazzanga
Mazzanga6mo ago
GitHub
GitHub - Papotta/portfolio
Contribute to Papotta/portfolio development by creating an account on GitHub.
Brody
Brody6mo ago
currently you have a backend and a frontend mushed together into a single directory, please separate them out into a /frontend and a /backend folder within this repo
Mazzanga
Mazzanga6mo ago
I doit but now i have this problem
No description
No description
Brody
Brody6mo ago
don't worry it it deploying successful yet, we aren't at that stage yet https://github.com/brody192/vite-react-template copy the nixpacks.toml and Caddyfile from this repo into your frontend folder and while you're at it, you can delete your "nixpack.toml" file, it's both spelt wrong and uses completely wrong syntax
Mazzanga
Mazzanga6mo ago
like this?
No description
Mazzanga
Mazzanga6mo ago
No description
Brody
Brody6mo ago
you spelt it wrong, please be careful with the spelling and the casing, it matters
Mazzanga
Mazzanga6mo ago
alredy corrected the Canddyfile Caddyfile*
Brody
Brody6mo ago
show me a screenshot of your railway project please
Mazzanga
Mazzanga6mo ago
No description
Mazzanga
Mazzanga6mo ago
its the same error than before, I have to install something?
Brody
Brody6mo ago
nope, I said not to worry about it failing yet go into it's settings and set the root directory to /frontend
Mazzanga
Mazzanga6mo ago
ready
Brody
Brody6mo ago
now we can worry about it failing so it should have redeployed after you made that change, let me know how the build goes
Mazzanga
Mazzanga6mo ago
it dont failt but I have this now
No description
No description
Brody
Brody6mo ago
how long ago did you add the domain to the service?
Mazzanga
Mazzanga6mo ago
5 minuts oh wait
Brody
Brody6mo ago
then the new domain hasn't propagated through the router yet, should work any minute now
Mazzanga
Mazzanga6mo ago
now I can see the static page
Brody
Brody6mo ago
awesome
Mazzanga
Mazzanga6mo ago
the only left is run the erver in the backend folder, its not running
Brody
Brody6mo ago
of course not, we need another railway service for that so go ahead and do that new railway service, and set the root directory to /backend
Mazzanga
Mazzanga6mo ago
So I upload the project from github again?
Brody
Brody6mo ago
yes
Mazzanga
Mazzanga6mo ago
and change the root directory to /backend?
Brody
Brody6mo ago
yep
Mazzanga
Mazzanga6mo ago
ok I'll try it ​ the server run good, but I can do request to them, the fetch send error 405 Mehod Not allowed, but iI verify and the cors its correct
Brody
Brody6mo ago
make sure you use http and specify the correct method when making the request
Mazzanga
Mazzanga6mo ago
In development it works without any problem, but in production the same error continues
Brody
Brody6mo ago
show me your fetch calls please
Mazzanga
Mazzanga6mo ago
ok give me a sec
Mazzanga
Mazzanga6mo ago
this one is in development
No description
Mazzanga
Mazzanga6mo ago
and this ins production
No description
Mazzanga
Mazzanga6mo ago
No description
Brody
Brody6mo ago
can you test your mail endpoint on railway locally from postman or a similar api testing app
Mazzanga
Mazzanga6mo ago
ok i will try
Mazzanga
Mazzanga6mo ago
No description
Mazzanga
Mazzanga6mo ago
I have to add a domain for the server?
Brody
Brody6mo ago
oh you are trying to call the wrong domain lol you need to add a domain to that backend service and then call that domain
Mazzanga
Mazzanga6mo ago
I supoused jja let me try
Mazzanga
Mazzanga6mo ago
try every way but I can delete the original domain of the frontend, I have set the variables environ correctly
No description
Mazzanga
Mazzanga6mo ago
No description
Mazzanga
Mazzanga6mo ago
and try this too but still calling the frontend domain
No description
Brody
Brody6mo ago
then you need to find out where you have your frontend domain hardcoded
Mazzanga
Mazzanga6mo ago
could be something of Caddyfile?
Brody
Brody6mo ago
nope
Mazzanga
Mazzanga6mo ago
thank you very much for your help in all this time
Brody
Brody6mo ago
where you able to get the frontend to call the correct domain?
Mazzanga
Mazzanga6mo ago
I dont found nothing wrong, so I change browser and works, it was cache