R
Railway11mo ago
Mazzanga

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
Mazzanga11mo ago
3161844c-1cfc-470c-995a-24c2de301990
Brody
Brody11mo ago
can you please share your repo?
Mazzanga
Mazzanga11mo ago
GitHub
GitHub - Papotta/portfolio
Contribute to Papotta/portfolio development by creating an account on GitHub.
Brody
Brody11mo 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
Mazzanga11mo ago
I doit but now i have this problem
No description
No description
Brody
Brody11mo 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
Mazzanga11mo ago
like this?
No description
Mazzanga
Mazzanga11mo ago
No description
Brody
Brody11mo ago
you spelt it wrong, please be careful with the spelling and the casing, it matters
Mazzanga
Mazzanga11mo ago
alredy corrected the Canddyfile Caddyfile*
Brody
Brody11mo ago
show me a screenshot of your railway project please
Mazzanga
Mazzanga11mo ago
No description
Mazzanga
Mazzanga11mo ago
its the same error than before, I have to install something?
Brody
Brody11mo ago
nope, I said not to worry about it failing yet go into it's settings and set the root directory to /frontend
Mazzanga
Mazzanga11mo ago
ready
Brody
Brody11mo 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
Mazzanga11mo ago
it dont failt but I have this now
No description
No description
Brody
Brody11mo ago
how long ago did you add the domain to the service?
Mazzanga
Mazzanga11mo ago
5 minuts oh wait
Brody
Brody11mo ago
then the new domain hasn't propagated through the router yet, should work any minute now
Mazzanga
Mazzanga11mo ago
now I can see the static page
Brody
Brody11mo ago
awesome
Mazzanga
Mazzanga11mo ago
the only left is run the erver in the backend folder, its not running
Brody
Brody11mo 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
Mazzanga11mo ago
So I upload the project from github again?
Brody
Brody11mo ago
yes
Mazzanga
Mazzanga11mo ago
and change the root directory to /backend?
Brody
Brody11mo ago
yep
Mazzanga
Mazzanga11mo 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
Brody11mo ago
make sure you use http and specify the correct method when making the request
Mazzanga
Mazzanga11mo ago
In development it works without any problem, but in production the same error continues
Brody
Brody11mo ago
show me your fetch calls please
Mazzanga
Mazzanga11mo ago
ok give me a sec
Mazzanga
Mazzanga11mo ago
this one is in development
No description
Mazzanga
Mazzanga11mo ago
and this ins production
No description
Mazzanga
Mazzanga11mo ago
No description
Brody
Brody11mo ago
can you test your mail endpoint on railway locally from postman or a similar api testing app
Mazzanga
Mazzanga11mo ago
ok i will try
Mazzanga
Mazzanga11mo ago
No description
Mazzanga
Mazzanga11mo ago
I have to add a domain for the server?
Brody
Brody11mo 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
Mazzanga11mo ago
I supoused jja let me try
Mazzanga
Mazzanga11mo ago
try every way but I can delete the original domain of the frontend, I have set the variables environ correctly
No description
Mazzanga
Mazzanga11mo ago
No description
Mazzanga
Mazzanga11mo ago
and try this too but still calling the frontend domain
No description
Brody
Brody11mo ago
then you need to find out where you have your frontend domain hardcoded
Mazzanga
Mazzanga11mo ago
could be something of Caddyfile?
Brody
Brody11mo ago
nope
Mazzanga
Mazzanga11mo ago
thank you very much for your help in all this time
Brody
Brody11mo ago
where you able to get the frontend to call the correct domain?
Mazzanga
Mazzanga11mo ago
I dont found nothing wrong, so I change browser and works, it was cache
Want results from more Discord servers?
Add your server