Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

production and dev differences. tinymce not rendering. due to no doctype in content from production server but doctype is in content from dev servers and the code is the same. #47

Open
jbrun001 opened this issue Mar 27, 2024 · 12 comments
Assignees
Labels
bug Something isn't working

Comments

@jbrun001
Copy link
Owner

No description provided.

@jbrun001
Copy link
Owner Author

jbrun001 commented Mar 27, 2024

TinyMCE failing: tinymce.min.js:4 Failed to initialize the editor as the document is not in standards mode. TinyMCE requires standards mode.
This works in dev on the same build so will need to review what linux is doing different.

jbrun001 added a commit that referenced this issue Mar 27, 2024
but working on dev
Changed
url: '/' + window.location.pathname.split('/')
.pop() + '-filtered',
to
url: window.location.pathname.split('/')
.pop() + '-filtered',
in filters.ejs
this stops it forcing the root url.
works in dev
jbrun001 added a commit that referenced this issue Mar 27, 2024
added addtional information in the PUBLIC
attribute of the doctype tag on each page
doesn't impact dev
@jbrun001
Copy link
Owner Author

jbrun001 commented Mar 27, 2024

Standards mode: the same HTML renders differently on uni server vs dev locally.
Same code viewing edit-booking
uni server:
Image
local dev:
Image

@jbrun001
Copy link
Owner Author

Same page, html response from uni on left and local on right
dev tools -> network, edit-booking, Response
The uni server is removing the doctype tag before responding. This is what's causing the problem
Image

@jbrun001 jbrun001 self-assigned this Mar 27, 2024
@jbrun001 jbrun001 added the bug Something isn't working label Mar 27, 2024
@jbrun001 jbrun001 changed the title production and dev differences due to URL dev: localhost:8000 (app is at root) production www.example.ac.uk/user/199 (app is not at root). Alter code and pages to accomodate both production and dev differences due to URL dev: localhost:8000 (app is at root) production www.example.ac.uk/user/199 (app is not at root). tinymce not rendering. Alter code and pages to accomodate both Mar 27, 2024
@jbrun001
Copy link
Owner Author

Created a new node .js simple test app in the production environment with just express that outputs a standards compliant html document.
const express = require('express')
const app = express()
const port = 8000
app.get('/', (req, res) => res.send('<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Test Document</title>
</head>
<body>
<h1>This is Test Doctype</h1>
</body>
</html>'));
app.listen(port, () => console.log('App2 listening on port ${port}!'))
ran this on the production environment: Same issue - doesn't render doctype.
Image
conclusion issue is not to do with any of the other packages we have used. Next test try testing with just node and no express

@jbrun001
Copy link
Owner Author

jbrun001 commented Mar 27, 2024

Simple app not using express to test if express is causing the issue - only using http package in node.
const http = require('http');
const port = 8000;
const server = http.createServer((req, res) => {
// Check the URL of the request
if (req.url === '/') {
// Set the response header for HTML content
res.writeHead(200, { 'Content-Type': 'text/html' });
// Send the HTML content
res.end('<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Test Document</title>
</head>
<body>
<h1>This is Test Doctype</h1>
</body>
</html>');
} else {
// If URL is not '/', return a 404 Not Found response
res.writeHead(404, { 'Content-Type': 'text/html' });
res.end('<h1>404 Not Found</h1>');
}
});
server.listen(port, () => {
console.log('Server listening on port ${port}!');
});
Result on the production server:
Image
Conclusion: this is the lowest level of output from node I can test. Conclusion is that the error is not happening in node and is not to do with any packages or any package versions that have been installed. Only other option is that this is happening in the web server.
I can see from the browser that the webserver is:
Server: Apache/2.4.41 (Ubuntu)
checking to see if apache is installed:
jbrun001@doc199:~/project/testdoctype$ httpd -v
Command 'httpd' not found, did you mean:
command 'xttpd' from deb xtide
command 'http' from deb httpie
Try: sudo apt install <deb name>
jbrun001@doc199:~/project/testdoctype$ apache2 -v
Command 'apache2' not found, but can be installed with:
sudo apt install apache2-bin
jbrun001@doc199:~/project/testdoctype$
Conclusion apache is not installed on this virtual machine, it is installed somewhere else and using port 8000 allows an apache server somewhere else that I can't see or edit the config for to render the page (and it's likely that apache is removing the doctype).

jbrun001 added a commit that referenced this issue Mar 27, 2024
this is to make it work with nginx routing.
for dev now use http://localhost:8001 and
NOT http://localhost:8000 which won't work
I will switch back if nginx doesn't solve
the doctype problem.
@jbrun001
Copy link
Owner Author

jbrun001 commented Mar 27, 2024

So next step is to install nginx locally and see if that defaults to working or has options to control the display of doctype. Space free before the install 827MB.
jbrun001@doc199:~/project$ df -h
/dev/mapper/vg-root 3.5G 2.5G 827M 76% /
install nginx
sudo apt install nginx
space free after install
/dev/mapper/vg-root 3.5G 2.5G 819M 76% /
nginx on /www/199
Image
apache still on /usr/199 - so looks like we might be able to roll back to this if needed.
No doctype in default nginx output - but might just be that it's not in the html for their default page...
jbrun001@doc199:~/project$ systemctl status nginx
● nginx.service - A high performance web server and a reverse proxy server
Loaded: loaded (/lib/systemd/system/nginx.service; enabled; vendor preset: enabled)
Active: active (running) since Wed 2024-03-27 13:07:51 GMT; 6min ago
Docs: man:nginx(8)
Main PID: 21445 (nginx)
Tasks: 2 (limit: 519)
CGroup: /system.slice/nginx.service
├─21445 nginx: master process /usr/sbin/nginx -g daemon on; master_process on;
└─21446 nginx: worker process
Mar 27 13:07:51 doc199 systemd[1]: Starting A high performance web server and a reverse proxy server...
Mar 27 13:07:51 doc199 systemd[1]: nginx.service: Failed to parse PID from file /run/nginx.pid: Invalid arg
Mar 27 13:07:51 doc199 systemd[1]: Started A high performance web server and a reverse proxy server.

run the app
cd /home/jbrun001/project/roombooking
forever start app.js
edit the config
sudo nano /etc/nginx/sites-available/default
add new lines in for the app above existing location / {, note I had to alter the port it runs on
location /bookit/ {
proxy_pass http://localhost:8001/;
}
restart ngix so the changes are implemented
sudo systemctl restart nginx
Image
Same response. No doctype.
code for that page:
Image
So changing the webserver doesn't make any difference. Not sure where else the issue could be. Going to review and double check everything.
stopping nginx because could waste disk space with logs
sudo systemctl stop nginx
changed port back to 8000 so can run on port 8000 through /usr/199
git pull origin main to get changes
now running on port 8000 and nginx is shut down.
using /usr/199 means content is now back to being served by apache

jbrun001 added a commit that referenced this issue Mar 27, 2024
no change using 8001 and nginx
jbrun001 added a commit that referenced this issue Mar 27, 2024
but some I've changes to test different cases
on the uni server
login.ejs - trying <!DOCTYPE html>
login-success.ejs trying <!DOCTYPE HTML>
bookings-list.ejs trying <!doctype html>
rooms-list.ejs trying <!doctype HTML>
everything else set to <!DOCTYPE html>
@jbrun001
Copy link
Owner Author

jbrun001 commented Mar 27, 2024

ok <!DOCTYPE html> is the accepted way of writing this and this conforms with the standards.
I'm going to try all permutations of this to see if there is something odd about the servers.
login.ejs - trying <!DOCTYPE html>
Image
login-success.ejs trying <!DOCTYPE HTML>
Image
bookings-list.ejs trying <!doctype html>
Image
rooms-list.ejs trying <!doctype HTML>
Image
Everything else set to <!DOCTYPE html>

so none of these changes made any difference.

jbrun001 added a commit that referenced this issue Mar 27, 2024
in /public to see what headers end up in the
browser testdoctype.html
@jbrun001
Copy link
Owner Author

jbrun001 commented Mar 27, 2024

next test. place a static html file in the application /public folder as a test. This file MUST be standardised HTML so it'll be a simple file that I will verify before placing in the /public folder. testdoctype.html
proof that webpage is a valid html standardised page:
image
result:
image
checking that not in source in the browser either
image
So a static file that is in the /public node folder (which is mapped to /) still has the doctype removed.

@jbrun001 jbrun001 changed the title production and dev differences due to URL dev: localhost:8000 (app is at root) production www.example.ac.uk/user/199 (app is not at root). tinymce not rendering. Alter code and pages to accomodate both production and dev differences. tinymce not rendering. due to no doctype in content from production server but doctype is content from dev servers Mar 27, 2024
@jbrun001 jbrun001 changed the title production and dev differences. tinymce not rendering. due to no doctype in content from production server but doctype is content from dev servers production and dev differences. tinymce not rendering. due to no doctype in content from production server but doctype is in content from dev servers and the code is the same. Mar 27, 2024
@jbrun001
Copy link
Owner Author

jbrun001 commented Mar 27, 2024

Only major difference between dev and production, aside from the webserver/proxying, is
uni server
jbrun001@doc199:~$ node -v
v16.17.0
home dev environment:
roombooking> node -v
v18.18.1
however ubuntu 18.04 doesn't support node v18, in particular the npm install bcrypt. ubuntu 20.04 does but creating a virtual server of ubuntu 20 doesnt have enough free space to install mysql, npm, node, etc. that's required, I guess because the disk size is the same as ubuntu18 but the os is much bigger - see work yesterday in issue #46, where I tried a ubuntu20 virtual server and that failed due to lack of space. I then went back to an ubuntu18 virtual server and recreated everything from scratch including the package.json because an ubuntu20.04 was not workable with so little free space.
Also tried manually using the myserver commands from https://www.doc.gold.ac.uk/intranet/virtualservers/ because theoretically you could specify more disk, but this command either doesn't now work or requires different permissions. The commands resulted in HTML output rather than any action.

Next test is to downgrade my dev environment to node 16.17.0 and see if that replicates the issue, which I'll do next

@jbrun001
Copy link
Owner Author

jbrun001 commented Mar 31, 2024

New plan. New things to try based on research.

  1. downgrade the development environment to node to 16.17 or the closest 16.x version I can get on windows. Re-install all the modules and see if the <!DOCTYPE is now removed on the development environment. Make the server version as my windows version and re-test.
  2. I found a way to have node v18 installed on v18.04 of ubuntu. This would be better than having 16.17. We are only on 16.17 on the server because node 18.x won't allow us to use bcrypt, 18.04 ubuntu doesn't have the /lib/x86_64-linux-gnu/libc.so.6: version `GLIBC_2.28' library and ubuntu 20 has all of these, but the uni ubuntu 20.04 virtual server doesn't have enough space, when created via the myserver webpage on the intranet, to install node and mysql let alone the other things. I know we think it's not node, but this is still something that can be tried. This way involves manually compiling the missing security library (see issue Planet scale hobby tier is closing down on 9 April which is the deadline for the project. The database will need to be moved before we submit the project. #46) on the server so it runs. The instructions don't look too crazy but if anything goes wrong I won't be able to re-create the virtual machine until I get to uni later this week. It might go wrong because of limited space or permissions. Here is the link I found about manually compiling the GLIBC_2.28: NodeJS 18 not working on Ubuntu 18.04 nodesource/distributions#1392

@jbrun001
Copy link
Owner Author

jbrun001 commented Mar 31, 2024

  1. Downgraded nodejs on my local windows dev environment to v16.20.2 (this is the lowest 16.x version I could find(.
    re-created package.json and re-installed all the packages required using the npm install line in the readme.md.
    Screenshot below. Shows that for the test page and the login page is visible in the browser view source code.
    image
    This isn't the exact version of nodejs that's on the server, but it does show that a 16.x version works on a windows development environment.
    I'll review if the next step is to upgrade the server to node.js v16.20.2 or go straight to v18.x option 2 from above which means tying to compile the /lib/x86_64-linux-gnu/libc.so.6: version `GLIBC_2.28 manually and comes with the risk that the server gets broken and is not fixable until I can get into uni later this week.

@jbrun001
Copy link
Owner Author

I have decided not to do the complication of the security library now. I think its better to work on the security headers which had to be switched off, becuase they were related to local host, so the app works on the server and on localhost. It's better to work on that before I try the v18 because if the v18 think breaks the server I won't be able to work on anything else on the server until I ca go into uni

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
Status: In Progress
Development

No branches or pull requests

1 participant