question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

PIXI JS CORS on Local

See original GitHub issue

Hello guys! I have this problem below 🆘

Expected Behavior

I want my html file to load on Google Chrome by just double clicking it. The images are in file:///C:/wamp64/www/sitefolder/imgs/

I want PixiJS to load them on

var texture = PIXI.Sprite.from(Image Path which is 'file:///C:/wamp64/www/sitefolder/imgs/image1.jpg');

Current Behavior

When I open the site on file:///C:/wamp64/www/sitefolder/site.html I have these errors:

1

Same error occurs when I try to load an image from external source like: https://image.freepik.com/free-photo/close-up-hand-holding-smartphone_23-2148989917.jpg even though I am on localhost

I tried

  • using canvas but wont let me do toDataURL() because the canvas was tainted

Steps to Reproduce

Open your a site with PIXI JS on file:///C:/wamp64/www/site.html

Environment

  • pixi.js version: I build mine here https://pixijs.io/customize/
  • Browser & Version: Version 91.0.4472.114 (Official Build) (64-bit)
  • OS & Version: Windows 10 21H1 (OS Build 19043.1052)
  • Running Example: N/A

Localhost

There is no issue when opening it on localhost/sitefolder/site.html I just want my users to see the sample of the code / animation / effect by just double clicking it on their folder or opening it on Google Chrome.

Thank you in advance!

Issue Analytics

  • State:closed
  • Created 2 years ago
  • Comments:8 (3 by maintainers)

github_iconTop GitHub Comments

1reaction
miltoncandelerocommented, Jun 24, 2021

You need to upload your web game so people can play it on the web 😛

itch.io is a free place to upload your game or if you want to make a computer game you can try wrapping it inside something like electron or nw.js

1reaction
photonstormcommented, Jun 24, 2021

Based on your path it looks like you’ve got WAMP installed, so you should be opening your HTML file through that, not via file://.

Have a read of the WAMP docs to get up to speed on how to access localhost via it. Until you do that, this error will persist, as browsers are not allowed to do pretty much anything when running via file:// (for good reason, too).

Read more comments on GitHub >

github_iconTop Results From Across the Web

pixijs load resource s been blocked by CORS policy: No ...
You will need to run a web server to develop locally with PixiJS. Web browsers prevent loading local files (such as images and...
Read more >
How to host image that can be accessed by PIXI.js without ...
I have been using PIXI.js to create a basic game. When I attempt to play the game at a remote location, I run...
Read more >
Cross origin problem (spritesheet & mp4) - Pixi.js
1. It Seems empty string is the solution for canvasRenderer, and I am using webgl. 2. My target server has proper CORS header,...
Read more >
Solution PIXI.JS CORS policy http-server not working - YouTube
Access to image at 'file://.....png' from origin 'null' has been blocked by CORS policy: Cross origin requests are only supported for ...
Read more >
PixiJS Getting Started - cjgammon
The quickest way to get started with PixiJS is with a helper class called PIXI.Application . This class combines and abstracts a bunch...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found