简体   繁体   English

ReactJS生产版本排除文件

[英]ReactJS production build excluding files

I'm new to ReactJS and just finished my first project. 我是ReactJS的新手,刚刚完成了我的第一个项目。

One of my components is a contact form that uses with a PHP file to send an email. 我的组件之一是联系表格,该表格与PHP文件一起使用以发送电子邮件。 On dev build, it works fine on localhost. 在开发版本上,它可以在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. 但是,一旦我替换PHP文件的localhost路径以直接链接并创建生产版本,我就会为PHP文件获得404。

Here is my folder structure 这是我的文件夹结构

在此处输入图片说明

And my link to contact.php from Contact component looks like const API_PATH = '/api/contact/contact.php'; 我从Contact组件到contact.php的链接看起来像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. 我通过将API文件夹移到生产版本文件夹中解决了该问题。

I'm not sure if it's the right way to do things but it worked. 我不确定这是否是正确的处理方式,但确实有效。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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