简体   繁体   中英

ReactJS production build excluding files

I'm new to ReactJS and just finished my first project.

One of my components is a contact form that uses with a PHP file to send an email. On dev build, it works fine on localhost.

But as soon as I replace the localhost path to the PHP file to direct link and create a production build, I get a 404 for the PHP file.

Here is my folder structure

在此处输入图片说明

And my link to contact.php from Contact component looks like const API_PATH = '/api/contact/contact.php';

在此处输入图片说明

What am I doing wrong?

I solved the issue by moving the API folder into the production build folder.

I'm not sure if it's the right way to do things but it worked.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM