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