Howdy!
This has been many days of trying to research however, either I am misunderstanding something or the solution online is not directred toward my issue.
I am running a node server on a sub-domain as such: xxx.yyy.com
I have express, socket.io and cors all installed.
My app.js file:
In my public folder I have a file 'testCors.html' which just outputs, Hello World.
Outside of the server, I have a file located here: www.yyy.com/testCors.php
As you can see, I just want the yyy.com/testCors.php page to alert 'Hello World' as found from xxx.yyy.com/textCors.html
However, I continue to get the CORS error.
Any related issues I can find online on stackoverflow, YT and here and other forums seems to talk about one port on localhost to another port, or receiving API from external domain, however I want my php page on public_html to receive.
I have also tried setting headers with PHP on client side but not having any luck with that either.
Any guidance will be greatly appreciated!
This has been many days of trying to research however, either I am misunderstanding something or the solution online is not directred toward my issue.
I am running a node server on a sub-domain as such: xxx.yyy.com
I have express, socket.io and cors all installed.
My app.js file:
JavaScript:
const http = require('http');
const express = require('express');
const app = express();
const cors = require('cors');
const server = require('http').createServer(app);
const path = require('path');
const io = require("socket.io")(server);
app.use(cors());
app.use('/', express.static(path.join(__dirname, 'public')));
io.on("connection", (socket) => {
});
server.listen();
In my public folder I have a file 'testCors.html' which just outputs, Hello World.
Outside of the server, I have a file located here: www.yyy.com/testCors.php
JavaScript:
<script src="_js/jquery-3.6.0.min.js"></script>
<script>
$( document ).ready(function() {
$.ajax({
type: "GET",
url: 'https://xxx.yyy.com/testCors.html',
dataType: "html",
success: function(result) {
alert(result);
}
});
});
</script>
As you can see, I just want the yyy.com/testCors.php page to alert 'Hello World' as found from xxx.yyy.com/textCors.html
However, I continue to get the CORS error.
Any related issues I can find online on stackoverflow, YT and here and other forums seems to talk about one port on localhost to another port, or receiving API from external domain, however I want my php page on public_html to receive.
I have also tried setting headers with PHP on client side but not having any luck with that either.
Any guidance will be greatly appreciated!