当我进入反应路由器的子目录下时,index.html链接和脚本无法加载。
// initiate connection to your S3 bucket
$client = new S3Client(['credentials' => ['key' => 's3 key', 'secret' =>'s3 secrete'], 'region' => 's3 region', 'version' => 'latest']);
$object = $client->getCommand('GetObject', [
'Bucket' => 's3 bucket',
'Key' => 'images/image.png' // file
]);
$presignedRequest = $client->createPresignedRequest($object, '+20 minutes');
$presignedUrl = (string)$presignedRequest->getUri();
if ($presignedUrl) {
return $presignedUrl;//presigned URL
} else {
throw new FileNotFoundException();
}
当我在/ foo路由中时,它很好。但是当我在/ foo / foo下时,出现此错误。例如,此路由为/ solutions / home。在控制台错误中,它转到/ solutions,然后从那里尝试从index.html导入scrs。我是否缺少某些内容?
index.html:
:1 Refused to apply style from 'http://localhost:3000/solutions/css/default.css' because its MIME type ('text/html') is not a supported stylesheet MIME type, and strict MIME checking is enabled.
答案 0 :(得分:0)
这是一个简单的..在思考并尝试调试了许多有关React和React路由器的内容之后,我意识到它根本没有用(哑巴),只需将%PUBLIC_URL%添加到所有链接文件中即可。问题在于使用react router index.html试图在路由器路由下获取这些文件。