Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

186
Views
How to load a local html file inside an iframe in my react application?

I'm having troubles when trying to load a html file from my public folder in a React application created with create-react-app. Am I missing a config setting somewhere in webpack?

I currently have this folder structure:

enter image description here

And I want to show the test.html file inside an Iframe in my React component like this:

import React from 'react';

const Component = props => {
  return (<iframe src="/test/index.html"title="Docuvieware" />);
};

export default Component;

But this is giving me a "Cannot GET /test/index.html" in the Iframe. Also when surfing directly to http://localhost:3000/test/index.html I get a white page that says 'Cannot GET /test/index.html'

I also tried to use "process.env.PUBLIC_URL" inside my component but this was undefined.

about 4 years ago · Juan Pablo Isaza
1 answers
Answer question

0

I have managed to fix this by using CopyWebpackPlugin. Just added the test folder in my src folder, and then added the following line to my webpack config:

new CopyWebpackPlugin([{ from: 'src/test', to: 'test' }]),

and then /test/index.html gave the correct path.

about 4 years ago · Juan Pablo Isaza Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!